diff --git a/internal/benchmarks/benchmarks_test.go b/internal/benchmarks/benchmarks_test.go index 5e89e50d..4db6df90 100644 --- a/internal/benchmarks/benchmarks_test.go +++ b/internal/benchmarks/benchmarks_test.go @@ -240,7 +240,7 @@ var migCreateTable = migrations.Migration{ { Name: "name", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, Unique: ptr(false), }, }, diff --git a/pkg/migrations/column.go b/pkg/migrations/column.go index 1d238c42..1da58fd4 100644 --- a/pkg/migrations/column.go +++ b/pkg/migrations/column.go @@ -4,10 +4,7 @@ package migrations // IsNullable returns true if the column is nullable func (c *Column) IsNullable() bool { - if c.Nullable != nil { - return *c.Nullable - } - return false + return c.Nullable } // IsUnique returns true if the column values must be unique diff --git a/pkg/migrations/op_add_column.go b/pkg/migrations/op_add_column.go index 0f506ed6..1d9cb1a6 100644 --- a/pkg/migrations/op_add_column.go +++ b/pkg/migrations/op_add_column.go @@ -202,7 +202,7 @@ func addColumn(ctx context.Context, conn db.DB, o OpAddColumn, t *schema.Table, // on migration completion // This is to avoid unnecessary exclusive table locks. if !o.Column.IsNullable() && o.Column.Default == nil { - o.Column.Nullable = ptr(true) + o.Column.Nullable = true } // Don't add a column with a CHECK constraint directly. diff --git a/pkg/migrations/op_add_column_test.go b/pkg/migrations/op_add_column_test.go index de7c6afc..aeb73de5 100644 --- a/pkg/migrations/op_add_column_test.go +++ b/pkg/migrations/op_add_column_test.go @@ -49,7 +49,7 @@ func TestAddColumn(t *testing.T) { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(false), + Nullable: false, Default: ptr("0"), Comment: ptr("the age of the user"), }, @@ -141,7 +141,7 @@ func TestAddColumn(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "integer", - Nullable: ptr(false), + Nullable: false, Unique: ptr(true), }, Up: "'this is a description'", @@ -182,7 +182,7 @@ func TestAddColumn(t *testing.T) { Column: migrations.Column{ Name: "counter_smallserial", Type: "smallserial", - Nullable: ptr(false), + Nullable: false, }, }, &migrations.OpAddColumn{ @@ -190,14 +190,14 @@ func TestAddColumn(t *testing.T) { Column: migrations.Column{ Name: "counter_serial", Type: "serial", - Nullable: ptr(false), + Nullable: false, }, }, &migrations.OpAddColumn{ Table: "users", Column: migrations.Column{ Name: "counter_bigserial", Type: "bigserial", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -311,7 +311,7 @@ func TestAddForeignKeyColumn(t *testing.T) { Table: "users", Column: "id", }, - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -413,7 +413,7 @@ func TestAddForeignKeyColumn(t *testing.T) { Table: "users", Column: "id", }, - Nullable: ptr(false), + Nullable: false, }, Up: "1", }, @@ -510,7 +510,7 @@ func TestAddForeignKeyColumn(t *testing.T) { Column: migrations.Column{ Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, References: &migrations.ForeignKeyReference{ Name: "fk_users_id", Table: "users", @@ -621,7 +621,7 @@ func TestAddForeignKeyColumn(t *testing.T) { Column: migrations.Column{ Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, References: &migrations.ForeignKeyReference{ Name: "fk_users_id", Table: "users", @@ -736,7 +736,7 @@ func TestAddColumnWithUpSql(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -818,7 +818,7 @@ func TestAddColumnWithUpSql(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -900,7 +900,7 @@ func TestAddColumnWithUpSql(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -982,7 +982,7 @@ func TestAddColumnWithUpSql(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -1051,7 +1051,7 @@ func TestAddColumnWithUpSql(t *testing.T) { Name: "name", Type: "varchar(255)", Unique: ptr(true), - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -1071,7 +1071,7 @@ func TestAddColumnWithUpSql(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -1165,7 +1165,7 @@ func TestAddNotNullColumnWithNoDefault(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -1238,7 +1238,7 @@ func TestAddColumnValidation(t *testing.T) { Name: "name", Type: "varchar(255)", Unique: ptr(true), - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -1259,7 +1259,7 @@ func TestAddColumnValidation(t *testing.T) { Name: "name", Type: "varchar(255)", Unique: ptr(true), - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -1279,7 +1279,7 @@ func TestAddColumnValidation(t *testing.T) { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(false), + Nullable: false, Default: ptr("0"), }, }, @@ -1319,7 +1319,7 @@ func TestAddColumnValidation(t *testing.T) { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -1536,7 +1536,7 @@ func TestAddColumnWithComment(t *testing.T) { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(false), + Nullable: false, Default: ptr("0"), Comment: ptr("the age of the user"), }, @@ -1687,7 +1687,7 @@ func TestAddColumnToATableCreatedInTheSameMigration(t *testing.T) { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(false), + Nullable: false, Default: ptr("18"), Check: &migrations.CheckConstraint{ Name: "age_check", diff --git a/pkg/migrations/op_alter_column_test.go b/pkg/migrations/op_alter_column_test.go index 5bf2216d..e3498df9 100644 --- a/pkg/migrations/op_alter_column_test.go +++ b/pkg/migrations/op_alter_column_test.go @@ -35,7 +35,7 @@ func TestAlterColumnMultipleSubOperations(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -191,7 +191,7 @@ func TestAlterColumnMultipleSubOperations(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -308,7 +308,7 @@ func TestAlterColumnMultipleSubOperations(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -379,7 +379,7 @@ func TestAlterColumnMultipleSubOperations(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -394,12 +394,12 @@ func TestAlterColumnMultipleSubOperations(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(true), + Nullable: true, }, { Name: "manages", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, diff --git a/pkg/migrations/op_change_type_test.go b/pkg/migrations/op_change_type_test.go index c584980a..3d873ecb 100644 --- a/pkg/migrations/op_change_type_test.go +++ b/pkg/migrations/op_change_type_test.go @@ -156,7 +156,7 @@ func TestChangeColumnType(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -176,7 +176,7 @@ func TestChangeColumnType(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "department_id", @@ -234,7 +234,7 @@ func TestChangeColumnType(t *testing.T) { Name: "age", Type: "text", Default: ptr("'0'"), - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -299,7 +299,7 @@ func TestChangeColumnType(t *testing.T) { Name: "username", Type: "text", Default: ptr("'alice'"), - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -363,7 +363,7 @@ func TestChangeColumnType(t *testing.T) { { Name: "age", Type: "text", - Nullable: ptr(true), + Nullable: true, Check: &migrations.CheckConstraint{ Name: "age_length", Constraint: "length(age) < 3", @@ -422,7 +422,7 @@ func TestChangeColumnType(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(true), + Nullable: true, Check: &migrations.CheckConstraint{ Name: "username_length", Constraint: "length(username) > 3", @@ -479,7 +479,7 @@ func TestChangeColumnType(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_common.go b/pkg/migrations/op_common.go index 0d6a144b..6e6a87ec 100644 --- a/pkg/migrations/op_common.go +++ b/pkg/migrations/op_common.go @@ -229,7 +229,3 @@ func OperationName(op Operation) OpName { panic(fmt.Errorf("unknown operation for %T", op)) } - -func ptr[T any](v T) *T { - return &v -} diff --git a/pkg/migrations/op_create_constraint_test.go b/pkg/migrations/op_create_constraint_test.go index fd2e2cfa..b2f2c087 100644 --- a/pkg/migrations/op_create_constraint_test.go +++ b/pkg/migrations/op_create_constraint_test.go @@ -34,7 +34,7 @@ func TestCreateConstraint(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -115,7 +115,7 @@ func TestCreateConstraint(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -189,12 +189,12 @@ func TestCreateConstraint(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "email", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -273,12 +273,12 @@ func TestCreateConstraint(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "email", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -376,12 +376,12 @@ func TestCreateConstraint(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "email", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -396,17 +396,17 @@ func TestCreateConstraint(t *testing.T) { { Name: "users_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, { Name: "users_zip", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, { Name: "description", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -520,12 +520,12 @@ func TestCreateConstraintValidation(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "registered_at_year", Type: "integer", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -565,7 +565,7 @@ func TestCreateConstraintValidation(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -609,7 +609,7 @@ func TestCreateConstraintValidation(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -655,7 +655,7 @@ func TestCreateConstraintValidation(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_create_index_test.go b/pkg/migrations/op_create_index_test.go index 9143d81e..ad8c67af 100644 --- a/pkg/migrations/op_create_index_test.go +++ b/pkg/migrations/op_create_index_test.go @@ -33,7 +33,7 @@ func TestCreateIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -79,7 +79,7 @@ func TestCreateIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -125,12 +125,12 @@ func TestCreateIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "registered_at_year", Type: "integer", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -178,12 +178,12 @@ func TestCreateIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "registered_at_year", Type: "integer", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -222,7 +222,7 @@ func TestCreateIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -278,12 +278,12 @@ func TestCreateIndexOnMultipleColumns(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "email", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -335,7 +335,7 @@ func TestCreateIndexOnObjectsCreatedInSameMigration(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -377,7 +377,7 @@ func TestCreateIndexOnObjectsCreatedInSameMigration(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -391,7 +391,7 @@ func TestCreateIndexOnObjectsCreatedInSameMigration(t *testing.T) { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, Up: "18", }, diff --git a/pkg/migrations/op_drop_column_test.go b/pkg/migrations/op_drop_column_test.go index 45351c9b..39867ecc 100644 --- a/pkg/migrations/op_drop_column_test.go +++ b/pkg/migrations/op_drop_column_test.go @@ -32,12 +32,12 @@ func TestDropColumnWithDownSQL(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "email", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_drop_constraint_test.go b/pkg/migrations/op_drop_constraint_test.go index 90e59925..524c15da 100644 --- a/pkg/migrations/op_drop_constraint_test.go +++ b/pkg/migrations/op_drop_constraint_test.go @@ -228,7 +228,7 @@ func TestDropConstraint(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -496,7 +496,7 @@ func TestDropConstraint(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -516,7 +516,7 @@ func TestDropConstraint(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "department_id", @@ -572,7 +572,7 @@ func TestDropConstraint(t *testing.T) { { Name: "title", Type: "text", - Nullable: ptr(true), + Nullable: true, Unique: ptr(true), }, }, @@ -640,7 +640,7 @@ func TestDropConstraint(t *testing.T) { { Name: "title", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -731,7 +731,7 @@ func TestDropConstraint(t *testing.T) { Name: "title", Type: "text", Unique: ptr(true), - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -782,7 +782,7 @@ func TestDropConstraint(t *testing.T) { Name: "title", Type: "text", Unique: ptr(true), - Nullable: ptr(false), + Nullable: false, Comment: ptr("the title of the post"), }, }, diff --git a/pkg/migrations/op_drop_index_test.go b/pkg/migrations/op_drop_index_test.go index fb5749c9..886e380a 100644 --- a/pkg/migrations/op_drop_index_test.go +++ b/pkg/migrations/op_drop_index_test.go @@ -30,7 +30,7 @@ func TestDropIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -84,7 +84,7 @@ func TestDropIndex(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_drop_multicolumn_constraint_test.go b/pkg/migrations/op_drop_multicolumn_constraint_test.go index ae38b43c..dbb6833f 100644 --- a/pkg/migrations/op_drop_multicolumn_constraint_test.go +++ b/pkg/migrations/op_drop_multicolumn_constraint_test.go @@ -275,7 +275,7 @@ func TestDropMultiColumnConstraint(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "zip", @@ -295,17 +295,17 @@ func TestDropMultiColumnConstraint(t *testing.T) { { Name: "description", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, { Name: "user_zip", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, diff --git a/pkg/migrations/op_drop_not_null_test.go b/pkg/migrations/op_drop_not_null_test.go index dc747f8d..8f71d9ba 100644 --- a/pkg/migrations/op_drop_not_null_test.go +++ b/pkg/migrations/op_drop_not_null_test.go @@ -34,17 +34,17 @@ func TestDropNotNull(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -150,17 +150,17 @@ func TestDropNotNull(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -216,7 +216,7 @@ func TestDropNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -236,12 +236,12 @@ func TestDropNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "department_id", Type: "integer", - Nullable: ptr(false), + Nullable: false, References: &migrations.ForeignKeyReference{ Name: "fk_employee_department", Table: "departments", @@ -293,7 +293,7 @@ func TestDropNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, Default: ptr("'anonymous'"), }, }, @@ -358,7 +358,7 @@ func TestDropNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, Check: &migrations.CheckConstraint{ Name: "name_length", Constraint: "length(name) > 3", @@ -415,7 +415,7 @@ func TestDropNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -491,7 +491,7 @@ func TestDropNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, Comment: ptr("the name of the user"), }, }, @@ -546,7 +546,7 @@ func TestDropNotNullValidation(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -583,7 +583,7 @@ func TestDropNotNullValidation(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, diff --git a/pkg/migrations/op_rename_column_test.go b/pkg/migrations/op_rename_column_test.go index b5d278e1..ff74878f 100644 --- a/pkg/migrations/op_rename_column_test.go +++ b/pkg/migrations/op_rename_column_test.go @@ -27,7 +27,7 @@ func TestRenameColumn(t *testing.T) { { Name: "username", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_rename_constraint_test.go b/pkg/migrations/op_rename_constraint_test.go index c61d6df0..ff69818d 100644 --- a/pkg/migrations/op_rename_constraint_test.go +++ b/pkg/migrations/op_rename_constraint_test.go @@ -29,7 +29,7 @@ func TestRenameConstraint(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, Check: &migrations.CheckConstraint{Constraint: `LENGTH("username") <= 2048`, Name: "users_text_length_username"}, }, }, diff --git a/pkg/migrations/op_set_check_test.go b/pkg/migrations/op_set_check_test.go index 4ad82339..179a5035 100644 --- a/pkg/migrations/op_set_check_test.go +++ b/pkg/migrations/op_set_check_test.go @@ -219,7 +219,7 @@ func TestSetCheckConstraint(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -239,12 +239,12 @@ func TestSetCheckConstraint(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "department_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, References: &migrations.ForeignKeyReference{ Name: "fk_employee_department", Table: "departments", @@ -365,7 +365,7 @@ func TestSetCheckConstraint(t *testing.T) { { Name: "title", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_set_default_test.go b/pkg/migrations/op_set_default_test.go index 256d41ff..f6c26c3d 100644 --- a/pkg/migrations/op_set_default_test.go +++ b/pkg/migrations/op_set_default_test.go @@ -33,7 +33,7 @@ func TestSetDefault(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -135,7 +135,7 @@ func TestSetDefault(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -237,7 +237,7 @@ func TestSetDefault(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, Default: ptr("'unknown user'"), }, }, @@ -339,7 +339,7 @@ func TestSetDefault(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, Default: ptr("'unknown user'"), }, }, diff --git a/pkg/migrations/op_set_fk_test.go b/pkg/migrations/op_set_fk_test.go index 8c3940a2..d6ee0fb6 100644 --- a/pkg/migrations/op_set_fk_test.go +++ b/pkg/migrations/op_set_fk_test.go @@ -51,7 +51,7 @@ func TestSetForeignKey(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -199,7 +199,7 @@ func TestSetForeignKey(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -288,7 +288,7 @@ func TestSetForeignKey(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -394,7 +394,7 @@ func TestSetForeignKey(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -503,7 +503,7 @@ func TestSetForeignKey(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, Default: ptr("3"), }, }, @@ -876,12 +876,12 @@ func TestSetForeignKey(t *testing.T) { { Name: "title", Type: "text", - Nullable: ptr(true), + Nullable: true, }, { Name: "user_id", Type: "integer", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -1138,7 +1138,7 @@ func TestSetForeignKey(t *testing.T) { { Name: "user_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, }, }, diff --git a/pkg/migrations/op_set_notnull_test.go b/pkg/migrations/op_set_notnull_test.go index 0159da77..b10c36d3 100644 --- a/pkg/migrations/op_set_notnull_test.go +++ b/pkg/migrations/op_set_notnull_test.go @@ -34,17 +34,17 @@ func TestSetNotNull(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -159,17 +159,17 @@ func TestSetNotNull(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -225,7 +225,7 @@ func TestSetNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -245,12 +245,12 @@ func TestSetNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "department_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, References: &migrations.ForeignKeyReference{ Name: "fk_employee_department", Table: "departments", @@ -303,7 +303,7 @@ func TestSetNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, Default: ptr("'anonymous'"), }, }, @@ -367,7 +367,7 @@ func TestSetNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, Check: &migrations.CheckConstraint{ Name: "name_length", Constraint: "length(name) > 3", @@ -423,7 +423,7 @@ func TestSetNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -498,7 +498,7 @@ func TestSetNotNull(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(true), + Nullable: true, Comment: ptr("the name of the user"), }, }, @@ -548,17 +548,17 @@ func TestSetNotNullValidation(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(true), + Nullable: true, }, }, }, @@ -601,17 +601,17 @@ func TestSetNotNullValidation(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_set_replica_identity_test.go b/pkg/migrations/op_set_replica_identity_test.go index be2d0479..c853c0e9 100644 --- a/pkg/migrations/op_set_replica_identity_test.go +++ b/pkg/migrations/op_set_replica_identity_test.go @@ -26,7 +26,7 @@ func TestSetReplicaIdentity(t *testing.T) { { Name: "name", Type: "varchar(255)", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/op_set_unique_test.go b/pkg/migrations/op_set_unique_test.go index b39102f3..ac090c15 100644 --- a/pkg/migrations/op_set_unique_test.go +++ b/pkg/migrations/op_set_unique_test.go @@ -33,17 +33,17 @@ func TestSetColumnUnique(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -114,17 +114,17 @@ func TestSetColumnUnique(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "review", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -258,7 +258,7 @@ func TestSetColumnUnique(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -278,12 +278,12 @@ func TestSetColumnUnique(t *testing.T) { { Name: "name", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "department_id", Type: "integer", - Nullable: ptr(true), + Nullable: true, References: &migrations.ForeignKeyReference{ Name: "fk_employee_department", Table: "departments", @@ -400,7 +400,7 @@ func TestSetColumnUnique(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, { Name: "product", @@ -461,7 +461,7 @@ func TestSetColumnUnique(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, Comment: ptr("the name of the user"), }, { @@ -524,7 +524,7 @@ func TestSetColumnUnique(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/pkg/migrations/types.go b/pkg/migrations/types.go index 3666ee3a..c75d9aaa 100644 --- a/pkg/migrations/types.go +++ b/pkg/migrations/types.go @@ -29,7 +29,7 @@ type Column struct { Name string `json:"name"` // Indicates if the column is nullable - Nullable *bool `json:"nullable,omitempty"` + Nullable bool `json:"nullable,omitempty"` // Indicates if the column is part of the primary key Pk bool `json:"pk,omitempty"` diff --git a/pkg/roll/execute_test.go b/pkg/roll/execute_test.go index cbcc4961..54cc2945 100644 --- a/pkg/roll/execute_test.go +++ b/pkg/roll/execute_test.go @@ -732,7 +732,7 @@ func TestSQLTransformerOptionIsUsedWhenCreatingTriggers(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -788,7 +788,7 @@ func TestSQLTransformerOptionIsUsedWhenCreatingTriggers(t *testing.T) { Column: migrations.Column{ Name: "description", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, @@ -859,7 +859,7 @@ func addColumnOp(tableName string) *migrations.OpAddColumn { Column: migrations.Column{ Name: "age", Type: "integer", - Nullable: ptr(true), + Nullable: true, }, } } diff --git a/pkg/state/history_test.go b/pkg/state/history_test.go index c05d7e07..f2e37662 100644 --- a/pkg/state/history_test.go +++ b/pkg/state/history_test.go @@ -34,7 +34,7 @@ func TestSchemaHistoryReturnsFullSchemaHistory(t *testing.T) { { Name: "username", Type: "text", - Nullable: ptr(false), + Nullable: false, }, }, }, diff --git a/schema.json b/schema.json index a9a60f69..349e8e2b 100644 --- a/schema.json +++ b/schema.json @@ -39,7 +39,8 @@ }, "nullable": { "description": "Indicates if the column is nullable", - "type": "boolean" + "type": "boolean", + "default": false }, "pk": { "description": "Indicates if the column is part of the primary key",