Closed lcjury closed 5 years ago
Additional information:
I'm able to reproduce this through the rails cli running a migration after switching to another tenant.
Apartment::Tenant.switch!("some_schema")
ActiveRecord::Migrator.run(:up, ActiveRecord::Migrator.migrations_paths, 20190108141736)
That code fails with the same error shown before. But the following code work correctly:
ActiveRecord::Migrator.run(:up, ActiveRecord::Migrator.migrations_paths, 20190108141736)
Apparently, this issue is related to dumps/restore.
I was moving my no-apartment databases using the following script to dump the data:
psql -h $HOST -U $USER -c "alter schema public rename to $SCHEMA_NAME;" $DB_NAME
pg_dump -F plain -h $HOST -U $USER -d $DB_NAME -n $SCHEMA_NAME --file $DUMP_FILE
psql -h $HOST -U $USER -c "alter schema $SCHEMA_NAME rename to public;" $DB_NAME
Then I just restored then using running them with psql.
What I'm doing now:
Instead of dumping the whole database, I'm dumping only the data, excluding the ar_internal_metadata
and the schema_migrations
. I only need to be carefull that the schema version on the recently created schema matchs the dump versions.
am i right in assuming it's not apartment related, or?
I have a migration with the following code:
and it fails with the following error:
Notice that,
job
andemployee
(from the error) are not the same table!if I change the migration to have only one
execute
statement it works without problems, I have issues when I have more than one.System configuration
Database: Postgres 9.6
Apartment version: 2.2.0
Apartment config (in
config/initializers/apartment.rb
or so):use_schemas
: true by defaultRails (or ActiveRecord) version: rails version 5.0.7.2 (activerecord-5.0.7.2)
Ruby version: 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]