[RUBY] Master various migration operations

Understand the application of migration

    1. Create a "migration" file and write code to change the DB structure (schema) in Ruby
  1. Apply (migrate) the created "migration" file to the database using the rails db: migrate command.
$ rails db:migrate

The migration file update / change / deletion is not applied unless the command is executed.

Raise or lower migration

Apply migration = ** Raise ** Cancel application = ** Lower **

schema.rb Rails will automatically output the current database structure to db / schema.rb. It is automatically output when you apply or remove the migration, and

db:schema.rb:dump

It is also possible to output manually with

Recommended Posts

Master various migration operations
Various rails migration operations
Various Ruby string operations