From 58415e7f953ca9b32bbb05fffdff985b770fe54c Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Sun, 18 Aug 2024 13:40:07 -0700 Subject: [PATCH] Deprecate allow_nulls and forbid_nulls since they were duplicated methods. Fixes #1054 --- spec/avram/migrator/alter_table_statement_spec.cr | 11 ----------- src/avram/migrator/alter_table_statement.cr | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/spec/avram/migrator/alter_table_statement_spec.cr b/spec/avram/migrator/alter_table_statement_spec.cr index 3862fcc9d..6c1ffeb65 100644 --- a/spec/avram/migrator/alter_table_statement_spec.cr +++ b/spec/avram/migrator/alter_table_statement_spec.cr @@ -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 diff --git a/src/avram/migrator/alter_table_statement.cr b/src/avram/migrator/alter_table_statement.cr index 221cf3d8b..4a65d95d0 100644 --- a/src/avram/migrator/alter_table_statement.cr +++ b/src/avram/migrator/alter_table_statement.cr @@ -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 @@ -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