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

Task gen.model doesn't honor default_columns of BaseModel #921

Open
richarddewit opened this issue Sep 26, 2019 · 1 comment
Open

Task gen.model doesn't honor default_columns of BaseModel #921

richarddewit opened this issue Sep 26, 2019 · 1 comment
Labels
feature request A new requested feature / option

Comments

@richarddewit
Copy link

Following the docs, I've changed the default_columns of the BaseModel, mainly to change the ID column type from Int64 to UUID:

abstract class BaseModel < Avram::Model
  macro default_columns
    # Sets the type for `id` to `UUID`
    primary_key id : UUID
    # adds the `created_at` and `updated_at` columns
    timestamps
  end

  def self.database
    AppDatabase
  end
end

Now after running lucky gen.model Todo, this happens:

Expected migration

  def migrate
    create table_for(Todo) do
      primary_key id : UUID
      add_timestamps
    end
  end

Actual migration

  def migrate
    create table_for(Todo) do
      primary_key id : Int64       # <-- the default type
      add_timestamps
    end
  end
@paulcsmith paulcsmith transferred this issue from luckyframework/lucky_cli Sep 26, 2019
@paulcsmith paulcsmith added the feature request A new requested feature / option label Sep 26, 2019
@paulcsmith
Copy link
Member

This may be tricky to do without a lot of changes. For now you'll have to manually change it to UUID in the migrations.

Maybe what we could do is add a setting to the migration generator that tells it to default to UUID, but that will require reworking some things in CLI. I'll see what we can do to improve this but it might be a bit. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new requested feature / option
Projects
None yet
Development

No branches or pull requests

2 participants