Use Ruby code to make database structure changes (DDL) like creating tables or adding columns.
Used in database level.
bundle exec rails generate migration CreateTasks
# db/migrate/TIMESTAMP_create_tasks.rb
class CreateTasks < ActiveRecord::Migration[7.1]
def change
create_table :tasks do |t|
t.text :title
t.timestamps
end
end
end
bundle exec rails db:migrate
bundle exec rails console
ActiveRecord::Base.connection.tables
rails db:schema:load to initializebundle exec rails db:rollback