Skip to content

Commit

Permalink
feature: db:migrate:reset:with_data
Browse files Browse the repository at this point in the history
Usually when resetting a database there is no data, but we use data migrations
to create table partitions so we need to make sure they run. (Having them as
schema migrations adds spurious changes to the schema every month).
  • Loading branch information
schwern committed Dec 15, 2020
1 parent a3b9b52 commit b7c04de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ You can generate a data migration as you would a schema migration:
rake db:forward:with_data # Pushes the schema to the next version (specify steps w/ STEP=n)
rake db:migrate:down:with_data # Runs the "down" for a given migration VERSION
rake db:migrate:redo:with_data # Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x)
rake db:migrate:reset:with_data # Drops and creates a fresh database and runs all migrations.
rake db:migrate:status:with_data # Display status of data and schema migrations
rake db:migrate:up:with_data # Runs the "up" for a given migration VERSION
rake db:migrate:with_data # Migrate the database data and schema (options: VERSION=x, VERBOSE=false)
Expand Down
5 changes: 5 additions & 0 deletions tasks/databases.rake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ namespace :db do
Rake::Task["data:dump"].invoke
end

namespace :reset do
desc 'Drops and creates a fresh database and runs all migrations.'
task with_data: ["db:drop", "db:create", "db:migrate:with_data"]
end

namespace :redo do
desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
task :with_data => :environment do
Expand Down

0 comments on commit b7c04de

Please sign in to comment.