has_and_belongs_to_many not deleting the table #22

Closed
cj opened this Issue Feb 16, 2012 · 6 comments

Comments

Projects
None yet
2 participants
@cj

cj commented Feb 16, 2012

If you remove a has_and_belongs_to_many association the table is not deleted.

@DAddYE

This comment has been minimized.

Show comment Hide comment
@DAddYE

DAddYE Feb 16, 2012

Owner

Try using only once like in after_load

ActiveRecord::Base.auto_upgrade!
Owner

DAddYE commented Feb 16, 2012

Try using only once like in after_load

ActiveRecord::Base.auto_upgrade!

@DAddYE DAddYE closed this Feb 16, 2012

@cj

This comment has been minimized.

Show comment Hide comment
@cj

cj Feb 16, 2012

That seems a bit extensive to be altering every single table..... should it not do it on the model level auto_upgrade like it does for everything else like indexes etc.... ?

cj commented Feb 16, 2012

That seems a bit extensive to be altering every single table..... should it not do it on the model level auto_upgrade like it does for everything else like indexes etc.... ?

@DAddYE

This comment has been minimized.

Show comment Hide comment
@DAddYE

DAddYE Feb 16, 2012

Owner

Alter only changed models, btw if you want to cleanup things open console and launch:

ActiveRecord::Base.clear_tables!
Owner

DAddYE commented Feb 16, 2012

Alter only changed models, btw if you want to cleanup things open console and launch:

ActiveRecord::Base.clear_tables!
@cj

This comment has been minimized.

Show comment Hide comment
@cj

cj Feb 16, 2012

For me it's altering every table and column on every app start (even if there is no change) when I have ActiveRecord::Base.auto_upgrade! in after_load

cj commented Feb 16, 2012

For me it's altering every table and column on every app start (even if there is no change) when I have ActiveRecord::Base.auto_upgrade! in after_load

@DAddYE

This comment has been minimized.

Show comment Hide comment
@DAddYE

DAddYE Feb 16, 2012

Owner

mmm, strange.

Can you write me your logs?

Owner

DAddYE commented Feb 16, 2012

mmm, strange.

Can you write me your logs?

WaYdotNET pushed a commit to WaYdotNET/mini_record that referenced this issue Feb 17, 2012

@cj

This comment has been minimized.

Show comment Hide comment
@cj

cj Feb 17, 2012

Thank you for those fixes :)

Seems like you shouldn't have to call ActiveRecord::Base.auto_upgrade! though. You should just be able to call auto_upgrade! on that model and have it delete that has_and_belongs_to_many table.

Also using ActiveRecord::Base.auto_upgrade! seems to add 2 or 3 seconds on to a load time. If I add a Model.auto_upgrade! to all my models it adds hardly anything to the load time. 1 or 2 ms maybe.

cj commented Feb 17, 2012

Thank you for those fixes :)

Seems like you shouldn't have to call ActiveRecord::Base.auto_upgrade! though. You should just be able to call auto_upgrade! on that model and have it delete that has_and_belongs_to_many table.

Also using ActiveRecord::Base.auto_upgrade! seems to add 2 or 3 seconds on to a load time. If I add a Model.auto_upgrade! to all my models it adds hardly anything to the load time. 1 or 2 ms maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment