Skip to content

Commit

Permalink
Add data_migrate gem, auto-migrate data when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Oct 2, 2024
1 parent 5b7d967 commit 550af5f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ gem 'base64', '~> 0.2.0'
gem 'mutex_m', '~> 0.2.0'
gem 'bigdecimal', '~> 3.1'
gem 'psych', '< 4'
gem "dotenv-rails", "~> 2.8"
gem 'dotenv-rails', '~> 2.8'
# pinned to < 9.3 until https://github.com/ilyakatz/data-migrate/issues/302 resolved
gem 'data_migrate', '~> 9.2', '< 9.3'
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ GEM
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
data_migrate (9.2.0)
activerecord (>= 6.1)
railties (>= 6.1)
date (3.3.4)
devise (4.7.3)
bcrypt (~> 3.0)
Expand Down Expand Up @@ -297,6 +300,7 @@ DEPENDENCIES
bigdecimal (~> 3.1)
bootsnap (~> 1.7.7)
byebug
data_migrate (~> 9.2, < 9.3)
devise (~> 4.7.1)
devise_token_auth (~> 1.1.5)
dotenv-rails (~> 2.8)
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
release: rails db:migrate
release: rails db:migrate:with_data
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -e production -C config/sidekiq.yml
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dm-2",
"description": "Digital Mappa 2",
"scripts": {
"postdeploy": "bundle exec rake db:migrate"
"postdeploy": "bundle exec rake db:migrate:with_data"
},
"repository": "https://github.com/performant-software/dm-2",
"env": {
Expand Down
2 changes: 1 addition & 1 deletion bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ chdir APP_ROOT do
system('bundle check') || system!('bundle install')

puts "\n== Updating database =="
system! 'bin/rails db:migrate'
system! 'bin/rails db:migrate:with_data'

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
Expand Down
3 changes: 3 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end

create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t|
end

create_table "document_folders", force: :cascade do |t|
t.string "title"
t.string "parent_type"
Expand Down

0 comments on commit 550af5f

Please sign in to comment.