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

Deprecate allow_nulls and forbid_nulls #1057

Merged
merged 1 commit into from
Aug 25, 2024
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
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