Skip to content

Commit

Permalink
Deprecate allow_nulls and forbid_nulls since they were duplicated met…
Browse files Browse the repository at this point in the history
…hods. Fixes #1054
  • Loading branch information
jwoertink committed Aug 18, 2024
1 parent a604962 commit 58415e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 0 additions & 11 deletions spec/avram/migrator/alter_table_statement_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ describe Avram::Migrator::AlterTableStatement do
built.statements[1].should eq "ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT '54';"
end

it "can change column nullability" do
built = Avram::Migrator::AlterTableStatement.new(:users).build do
forbid_nulls_for :id
allow_nulls_for :age
end

built.statements.size.should eq 2
built.statements[0].should eq "ALTER TABLE users ALTER COLUMN id SET NOT NULL;"
built.statements[1].should eq "ALTER TABLE users ALTER COLUMN age DROP NOT NULL;"
end

describe "fill_existing_with" do
it "fills existing with value and sets column to be non-null for non-null types" do
built = Avram::Migrator::AlterTableStatement.new(:users).build do
Expand Down
2 changes: 2 additions & 0 deletions src/avram/migrator/alter_table_statement.cr
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Avram::Migrator::AlterTableStatement
# allow_nulls_for :email
# end
# ```
@[Deprecated("Use make_optional instead")]
macro allow_nulls_for(column_name)
change_nullability_statements << build_nullability_statement({{column_name.id.stringify}}, true)
end
Expand All @@ -97,6 +98,7 @@ class Avram::Migrator::AlterTableStatement
# forbid_nulls_for :email
# end
# ```
@[Deprecated("Use make_required instead")]
macro forbid_nulls_for(column_name)
change_nullability_statements << build_nullability_statement({{column_name.id.stringify}}, false)
end
Expand Down

0 comments on commit 58415e7

Please sign in to comment.