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

add_belongs_to uses bigint in AlterTable statements #224

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spec/migrator/alter_table_statement_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ describe Avram::Migrator::AlterTableStatement do

built.statements.first.should eq <<-SQL
ALTER TABLE comments
ADD user_id int NOT NULL REFERENCES users ON DELETE CASCADE,
ADD post_id int REFERENCES posts ON DELETE RESTRICT,
ADD category_label_id int NOT NULL REFERENCES custom_table ON DELETE SET NULL,
ADD employee_id int NOT NULL REFERENCES users ON DELETE CASCADE,
ADD user_id bigint NOT NULL REFERENCES users ON DELETE CASCADE,
ADD post_id bigint REFERENCES posts ON DELETE RESTRICT,
ADD category_label_id bigint NOT NULL REFERENCES custom_table ON DELETE SET NULL,
ADD employee_id bigint NOT NULL REFERENCES users ON DELETE CASCADE,
ADD line_item_id uuid NOT NULL REFERENCES line_items ON DELETE CASCADE
SQL

Expand Down
2 changes: 1 addition & 1 deletion src/avram/migrator/alter_table_statement.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Avram::Migrator::AlterTableStatement
end

# Adds a references column and index given a model class and references option.
macro add_belongs_to(type_declaration, on_delete, references = nil, foreign_key_type = Int32)
macro add_belongs_to(type_declaration, on_delete, references = nil, foreign_key_type = Int64)
{% unless type_declaration.is_a?(TypeDeclaration) %}
{% raise "add_belongs_to expected a type declaration like 'user : User', instead got: '#{type_declaration}'" %}
{% end %}
Expand Down