DataMapper: using auto_migrate! with many to many addictions?

I am trying to port my application from MySql to Postgresql using Rails3-pre and the latest DataMapper.

I have several models that are linked through many-to-many relationships using: through => Resource, which means that DataMapper creates a connection table with foreign keys for both models. I can not auto_migrate! these changes because I keep getting this:

ERROR:  cannot drop table users because other objects depend on it
DETAIL:  constraint artist_users_owner_fk on table artist_users depends on table users
constraint site_users_owner_fk on table site_users depends on table users
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

I tried everything I could think of and thought everything worked for me when I added: constraint =>: skip the field definition, but I continue to get this error when I try to run auto_migrate. I thought: skip means it will ignore dependents, but maybe this only applies to deleting rows and not dropping tables?

I should mention that I can run auto_migrate after I nuke db once, but after that error.

Any suggestions or tips that really appreciate.

Edit: Gibheer on datamapper irc suggested using auto_upgrade instead - it is not trying to recreate tables.

+3
source share
2 answers

, - DataMapper.finalize.auto_migrate!, . , .

+1

, auto_migrate auto_upgrade.

, , , , , , , .

(/ ) .

0

Source: https://habr.com/ru/post/1746334/


All Articles