forked from ruby-china/homeland
-
Notifications
You must be signed in to change notification settings - Fork 4
data migrations after updating
Lan edited this page Sep 28, 2020
·
10 revisions
psql> CREATE DATABASE tmp_testerhome;
> psql -d tmp_testerhome
tmp_testerhome=# ALTER TABLE topics RENAME excellent TO grade;
tmp_testerhome=# DROP TABLE IF EXISTS posts;
tmp_testerhome=# ALTER TABLE users DROP COLUMN verified;
只需要导出数据不需要schema,同时也不需要导出migration,因为migration的数据需要通过db:migrate来生成
pg_dump --data-only -d tmp_testerhome -T schema_migrations > new_database
> bin/rails db:create
> bin/rails db:migrate
cat new_database | psql testerhome-dev
> bin/rails c
> require "./db/migrate/20200721022652_migrate_profile_data.rb"
> MigrateProfileData.new.up