Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddAssociationToAudits problem when upgrading the gem #64

Closed
tispratik opened this issue Jun 20, 2011 · 5 comments
Closed

AddAssociationToAudits problem when upgrading the gem #64

tispratik opened this issue Jun 20, 2011 · 5 comments

Comments

@tispratik
Copy link

I upgraded my application from rails 2 to rails 3.0.3 and when i run the upgrade migrations generated by acts_as_audited gem, i get the following error.

== AddAssociationToAudits: migrating =========================================
-- add_column(:audits, :association_id, :integer, {})
-> 0.0014s
-- add_foreign_key(:audits, :association_id, "associations", :id, {})
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR: relation "associations" does not exist
: ALTER TABLE audits ADD FOREIGN KEY (association_id) REFERENCES associations (id) DEFERRABLE

The first 3 migrations ran successfully.
== AddCommentToAudits: migrating =============================================
-- add_column(:audits, :comment, :string, {})
-> 0.0930s
== AddCommentToAudits: migrated (0.0961s) ====================================

== RenameChangesToAuditedChanges: migrating ==================================
-- rename_column(:audits, :changes, :audited_changes)
-> 0.0011s
== RenameChangesToAuditedChanges: migrated (0.0019s) =========================

== AddRemoteAddressToAudits: migrating =======================================
-- add_column(:audits, :remote_address, :string, {})
-> 0.0012s
== AddRemoteAddressToAudits: migrated (0.0017s) ==============================

Thanks

@tispratik
Copy link
Author

I think this commit https://github.com/ineu/acts_as_audited/commit/ba013fbc206f18f78a808d76de7a4371144b93c0 fixes it, but not the generator.

@ineu
Copy link

ineu commented Jun 20, 2011

tispratik, I don't think it does, it's aim is different. Furthermore, AddAssociationToAudits generator doesn't create any index/foreign keys constraints. Maybe you have some gem that handles foreign keys automatically? I'd recommend you to check your migration. Mine looks this way: https://gist.github.com/1036557

@tispratik
Copy link
Author

Thanks @ineu, my migration file looks the same too.
And you are right, i am using the gem https://github.com/weplay/redhillonrails_core for managing the fk relations.
Are you not facing this issue?

@ineu
Copy link

ineu commented Jun 20, 2011

No. Though i use no gems for FK support.

@tomkrus
Copy link

tomkrus commented Jul 26, 2011

ineu - thanx for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants