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

Table backend migration generator doesn't actually create a table #67

Closed
Quintasan opened this issue Aug 8, 2017 · 4 comments
Closed

Comments

@Quintasan
Copy link

rails generate mobility:translations project title:string description:string story:string

yields

class CreateProjectTitleAndDescriptionAndStoryTranslationsForMobilityTableBackend < ActiveRecord::Migration[5.1]
  def change
    add_column :project_translations, :title, :string
    add_column :project_translations, :description, :string
    add_column :project_translations, :story, :string
  end
end

Which doesn't work if project_translations table doesn't exist beforehand.

This should be either mentioned in the documentation explicitly or the generator should assume there's no such a table and create an appropriate migration.

@Quintasan
Copy link
Author

Actually scratch that. I passed ``--backend=table` and it worked.

Not sure why I had to do this since I had :table set as the backend in the initializer.

@shioyama
Copy link
Owner

shioyama commented Aug 8, 2017

It should pick up the backend if you put it in the initializer, so I consider this a bug. I'll look into it, thanks.

@Quintasan
Copy link
Author

@shioyama I can't reproduce it on a fresh Rails project so I guess I must have made some stupid mistake. Sorry for taking your time.

@shioyama
Copy link
Owner

shioyama commented Aug 9, 2017

The only thing that would trigger using the "add columns" template rather than the default "create table" template is the existence of a table project_translations, which it checks for here. But I'm not sure why setting the backend explicitly would change the result in that case... anyway, if it works on a fresh project I agree with closing. Let me know if you see it again.

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

No branches or pull requests

2 participants