Skip to content

Commit

Permalink
add_belongs_to uses bigint in AlterTable statements (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardloveall authored and paulcsmith committed Sep 4, 2019
1 parent 65c28b4 commit 9236380
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit 9236380

Please sign in to comment.