{"action":"opened","issue":{"url":"https://api.github.com/repos/thefrontiergroup/frontier_generators/issues/80","labels_url":"https://api.github.com/repos/thefrontiergroup/frontier_generators/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/thefrontiergroup/frontier_generators/issues/80/comments","events_url":"https://api.github.com/repos/thefrontiergroup/frontier_generators/issues/80/events","html_url":"https://github.com/thefrontiergroup/frontier_generators/issues/80","id":115425282,"number":80,"title":"Migrations for attributes with different class names are broken","user":{"login":"Ruxton","id":382760,"avatar_url":"https://avatars.githubusercontent.com/u/382760?v=3","gravatar_id":"","url":"https://api.github.com/users/Ruxton","html_url":"https://github.com/Ruxton","followers_url":"https://api.github.com/users/Ruxton/followers","following_url":"https://api.github.com/users/Ruxton/following{/other_user}","gists_url":"https://api.github.com/users/Ruxton/gists{/gist_id}","starred_url":"https://api.github.com/users/Ruxton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ruxton/subscriptions","organizations_url":"https://api.github.com/users/Ruxton/orgs","repos_url":"https://api.github.com/users/Ruxton/repos","events_url":"https://api.github.com/users/Ruxton/events{/privacy}","received_events_url":"https://api.github.com/users/Ruxton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-06T03:08:52Z","updated_at":"2015-11-06T03:08:52Z","closed_at":null,"body":"```\r\ninterview_questionnaire:\r\n  namespaces: [\"member\"]\r\n  skip_seeds: true\r\n  attributes:\r\n    gp_address:\r\n      show_on_index: false\r\n      type: belongs_to\r\n      class_name: \"Address\"\r\n```\r\n\r\nwill generate the following migration\r\n\r\n```\r\nclass CreateInterviewQuestionnaire < ActiveRecord::Migration\r\n  def change\r\n    create_table :interview_questionnaires do |t|\r\n      t.belongs_to :gp_address, index: true, foreign_key: true\r\n      t.datetime :created_at\r\n      t.datetime :updated_at\r\n      t.datetime :deleted_at\r\n    end\r\n    add_index :interview_questionnaires, :deleted_at\r\n  end\r\nend\r\n```\r\n\r\nThis will fail ```PGError: ERROR: relation “gp_address” does not exist```.  The migration requires a 'references' component, which you can't use foreign_key: true on :/.  Migration should end up looking like this for it to work.\r\n\r\n```\r\nclass CreateInterviewQuestionnaire < ActiveRecord::Migration\r\n  def change\r\n    create_table :interview_questionnaires do |t|\r\n      t.belongs_to :gp_address, references: :addresses, index: true\r\n      t.datetime :created_at\r\n      t.datetime :updated_at\r\n      t.datetime :deleted_at\r\n    end\r\n    add_index :interview_questionnaires, :deleted_at\r\n    add_foreign_key :interview_questionnaires, :addresses, column: :gp_address_id\r\n  end\r\nend\r\n```\r\n\r\n"}}