From 383f26f88169164ef45dcfbc4ba1c1845fce04ee Mon Sep 17 00:00:00 2001 From: Bowen Date: Thu, 21 Nov 2024 17:05:43 +0800 Subject: [PATCH] feat: [#280] Add Time methods --- contracts/database/schema/blueprint.go | 22 + contracts/database/schema/column.go | 8 + contracts/database/schema/grammar.go | 14 + database/schema/blueprint.go | 86 +++ database/schema/column.go | 55 +- database/schema/grammars/mysql.go | 70 +- database/schema/grammars/postgres.go | 44 +- database/schema/grammars/sqlite.go | 46 +- database/schema/grammars/sqlserver.go | 56 +- database/schema/schema_test.go | 816 +++++++++++----------- mocks/database/schema/Blueprint.go | 640 +++++++++++++++++ mocks/database/schema/ColumnDefinition.go | 186 +++++ mocks/database/schema/Grammar.go | 322 +++++++++ 13 files changed, 1915 insertions(+), 450 deletions(-) diff --git a/contracts/database/schema/blueprint.go b/contracts/database/schema/blueprint.go index 092ff3ee8..42b008567 100644 --- a/contracts/database/schema/blueprint.go +++ b/contracts/database/schema/blueprint.go @@ -15,6 +15,12 @@ type Blueprint interface { Char(column string, length ...int) ColumnDefinition // Create Indicate that the table needs to be created. Create() + // Date Create a new date column on the table. + Date(column string) ColumnDefinition + // DateTime Create a new date-time column on the table. + DateTime(column string, precision ...int) ColumnDefinition + // DateTimeTz Create a new date-time column (with time zone) on the table. + DateTimeTz(column string, precision ...int) ColumnDefinition // Decimal Create a new decimal column on the table. Decimal(column string) ColumnDefinition // Double Create a new double column on the table. @@ -65,10 +71,26 @@ type Blueprint interface { SmallIncrements(column string) ColumnDefinition // SmallInteger Create a new small integer (2-byte) column on the table. SmallInteger(column string) ColumnDefinition + // SoftDeletes Add a "deleted at" timestamp for the table. + SoftDeletes(column ...string) ColumnDefinition + // SoftDeletesTz Add a "deleted at" timestampTz for the table. + SoftDeletesTz(column ...string) ColumnDefinition // String Create a new string column on the table. String(column string, length ...int) ColumnDefinition // Text Create a new text column on the table. Text(column string) ColumnDefinition + // Time Create a new time column on the table. + Time(column string, precision ...int) ColumnDefinition + // TimeTz Create a new time column (with time zone) on the table. + TimeTz(column string, precision ...int) ColumnDefinition + // Timestamp Create a new time column on the table. + Timestamp(column string, precision ...int) ColumnDefinition + // Timestamps Add nullable creation and update timestamps to the table. + Timestamps(precision ...int) + // TimestampsTz Add creation and update timestampTz columns to the table. + TimestampsTz(precision ...int) + // TimestampTz Create a new time column (with time zone) on the table. + TimestampTz(column string, precision ...int) ColumnDefinition // TinyIncrements Create a new auto-incrementing tiny integer (1-byte) column on the table. TinyIncrements(column string) ColumnDefinition // TinyInteger Create a new tiny integer (1-byte) column on the table. diff --git a/contracts/database/schema/column.go b/contracts/database/schema/column.go index ebcd25b01..d767ad5dd 100644 --- a/contracts/database/schema/column.go +++ b/contracts/database/schema/column.go @@ -5,6 +5,8 @@ type ColumnDefinition interface { AutoIncrement() ColumnDefinition // Comment sets the comment value Comment(comment string) ColumnDefinition + // Default set the default value + Default(def any) ColumnDefinition // GetAllowed returns the allowed value GetAllowed() []string // GetAutoIncrement returns the autoIncrement value @@ -27,8 +29,14 @@ type ColumnDefinition interface { GetTotal() int // GetType returns the type value GetType() string + // GetUseCurrent returns the useCurrent value + GetUseCurrent() bool + // GetUseCurrentOnUpdate returns the useCurrentOnUpdate value + GetUseCurrentOnUpdate() bool // IsSetComment returns true if the comment value is set IsSetComment() bool + // OnUpdate sets the column to use the value on update + OnUpdate(value string) ColumnDefinition // Places set the decimal places Places(places int) ColumnDefinition // Total set the decimal total diff --git a/contracts/database/schema/grammar.go b/contracts/database/schema/grammar.go index 72e938ada..2986b8061 100644 --- a/contracts/database/schema/grammar.go +++ b/contracts/database/schema/grammar.go @@ -39,6 +39,12 @@ type Grammar interface { TypeBigInteger(column ColumnDefinition) string // TypeChar Create the column definition for a char type. TypeChar(column ColumnDefinition) string + // TypeDate Create the column definition for a date type. + TypeDate(column ColumnDefinition) string + // TypeDateTime Create the column definition for a date-time type. + TypeDateTime(column ColumnDefinition) string + // TypeDateTimeTz Create the column definition for a date-time (with time zone) type. + TypeDateTimeTz(column ColumnDefinition) string // TypeDecimal Create the column definition for a decimal type. TypeDecimal(column ColumnDefinition) string // TypeDouble Create the column definition for a double type. @@ -61,6 +67,14 @@ type Grammar interface { TypeMediumText(column ColumnDefinition) string // TypeText Create the column definition for a text type. TypeText(column ColumnDefinition) string + // TypeTime Create the column definition for a time type. + TypeTime(column ColumnDefinition) string + // TypeTimeTz Create the column definition for a time (with time zone) type. + TypeTimeTz(column ColumnDefinition) string + // TypeTimestamp Create the column definition for a timestamp type. + TypeTimestamp(column ColumnDefinition) string + // TypeTimestampTz Create the column definition for a timestamp (with time zone) type. + TypeTimestampTz(column ColumnDefinition) string // TypeTinyInteger Create the column definition for a tiny integer type. TypeTinyInteger(column ColumnDefinition) string // TypeTinyText Create the column definition for a tiny text type. diff --git a/database/schema/blueprint.go b/database/schema/blueprint.go index 549f9d583..51dc557a4 100644 --- a/database/schema/blueprint.go +++ b/database/schema/blueprint.go @@ -64,6 +64,28 @@ func (r *Blueprint) Decimal(column string) schema.ColumnDefinition { return r.createAndAddColumn("decimal", column) } +func (r *Blueprint) Date(column string) schema.ColumnDefinition { + return r.createAndAddColumn("date", column) +} + +func (r *Blueprint) DateTime(column string, precision ...int) schema.ColumnDefinition { + columnImpl := r.createAndAddColumn("dateTime", column) + if len(precision) > 0 { + columnImpl.precision = &precision[0] + } + + return columnImpl +} + +func (r *Blueprint) DateTimeTz(column string, precision ...int) schema.ColumnDefinition { + columnImpl := r.createAndAddColumn("dateTimeTz", column) + if len(precision) > 0 { + columnImpl.precision = &precision[0] + } + + return columnImpl +} + func (r *Blueprint) Double(column string) schema.ColumnDefinition { return r.createAndAddColumn("double", column) } @@ -192,6 +214,24 @@ func (r *Blueprint) SmallInteger(column string) schema.ColumnDefinition { return r.createAndAddColumn("smallInteger", column) } +func (r *Blueprint) SoftDeletes(column ...string) schema.ColumnDefinition { + newColumn := "deleted_at" + if len(column) > 0 { + newColumn = column[0] + } + + return r.Timestamp(newColumn).Nullable() +} + +func (r *Blueprint) SoftDeletesTz(column ...string) schema.ColumnDefinition { + newColumn := "deleted_at" + if len(column) > 0 { + newColumn = column[0] + } + + return r.TimestampTz(newColumn).Nullable() +} + func (r *Blueprint) String(column string, length ...int) schema.ColumnDefinition { defaultLength := constants.DefaultStringLength if len(length) > 0 { @@ -208,6 +248,52 @@ func (r *Blueprint) Text(column string) schema.ColumnDefinition { return r.createAndAddColumn("text", column) } +func (r *Blueprint) Time(column string, precision ...int) schema.ColumnDefinition { + columnImpl := r.createAndAddColumn("time", column) + if len(precision) > 0 { + columnImpl.precision = &precision[0] + } + + return columnImpl +} + +func (r *Blueprint) TimeTz(column string, precision ...int) schema.ColumnDefinition { + columnImpl := r.createAndAddColumn("timeTz", column) + if len(precision) > 0 { + columnImpl.precision = &precision[0] + } + + return columnImpl +} + +func (r *Blueprint) Timestamp(column string, precision ...int) schema.ColumnDefinition { + columnImpl := r.createAndAddColumn("timestamp", column) + if len(precision) > 0 { + columnImpl.precision = &precision[0] + } + + return columnImpl +} + +func (r *Blueprint) Timestamps(precision ...int) { + r.Timestamp("created_at", precision...).Nullable() + r.Timestamp("updated_at", precision...).Nullable() +} + +func (r *Blueprint) TimestampsTz(precision ...int) { + r.TimestampTz("created_at", precision...).Nullable() + r.TimestampTz("updated_at", precision...).Nullable() +} + +func (r *Blueprint) TimestampTz(column string, precision ...int) schema.ColumnDefinition { + columnImpl := r.createAndAddColumn("timestampTz", column) + if len(precision) > 0 { + columnImpl.precision = &precision[0] + } + + return columnImpl +} + func (r *Blueprint) TinyIncrements(column string) schema.ColumnDefinition { return r.UnsignedTinyInteger(column).AutoIncrement() } diff --git a/database/schema/column.go b/database/schema/column.go index 5c2a93240..d60476b8a 100644 --- a/database/schema/column.go +++ b/database/schema/column.go @@ -6,18 +6,21 @@ import ( ) type ColumnDefinition struct { - allowed []string - autoIncrement *bool - comment *string - def any - length *int - name *string - nullable *bool - places *int - precision *int - total *int - ttype *string - unsigned *bool + allowed []string + autoIncrement *bool + comment *string + def any + length *int + name *string + nullable *bool + onUpdate *string + places *int + precision *int + total *int + ttype *string + unsigned *bool + useCurrent *bool + useCurrentOnUpdate *bool } func (r *ColumnDefinition) AutoIncrement() schema.ColumnDefinition { @@ -32,6 +35,12 @@ func (r *ColumnDefinition) Comment(comment string) schema.ColumnDefinition { return r } +func (r *ColumnDefinition) Default(def any) schema.ColumnDefinition { + r.def = def + + return r +} + func (r *ColumnDefinition) GetAllowed() []string { return r.allowed } @@ -112,6 +121,22 @@ func (r *ColumnDefinition) GetType() (ttype string) { return } +func (r *ColumnDefinition) GetUseCurrent() (useCurrent bool) { + if r.useCurrent != nil { + return *r.useCurrent + } + + return +} + +func (r *ColumnDefinition) GetUseCurrentOnUpdate() (useCurrentOnUpdate bool) { + if r.useCurrentOnUpdate != nil { + return *r.useCurrentOnUpdate + } + + return +} + func (r *ColumnDefinition) IsSetComment() bool { return r != nil && r.comment != nil } @@ -122,6 +147,12 @@ func (r *ColumnDefinition) Nullable() schema.ColumnDefinition { return r } +func (r *ColumnDefinition) OnUpdate(value string) schema.ColumnDefinition { + r.onUpdate = convert.Pointer(value) + + return r +} + func (r *ColumnDefinition) Places(places int) schema.ColumnDefinition { r.places = convert.Pointer(places) diff --git a/database/schema/grammars/mysql.go b/database/schema/grammars/mysql.go index 3cdc869ae..5ab7f4c97 100644 --- a/database/schema/grammars/mysql.go +++ b/database/schema/grammars/mysql.go @@ -214,6 +214,33 @@ func (r *Mysql) TypeChar(column schema.ColumnDefinition) string { return fmt.Sprintf("char(%d)", column.GetLength()) } +func (r *Mysql) TypeDate(column schema.ColumnDefinition) string { + return "date" +} + +func (r *Mysql) TypeDateTime(column schema.ColumnDefinition) string { + current := "CURRENT_TIMESTAMP" + if column.GetPrecision() > 0 { + current = fmt.Sprintf("CURRENT_TIMESTAMP(%d)", column.GetPrecision()) + } + if column.GetUseCurrent() { + column.Default(current) + } + if column.GetUseCurrentOnUpdate() { + column.OnUpdate(current) + } + + if column.GetPrecision() > 0 { + return fmt.Sprintf("datetime(%d)", column.GetPrecision()) + } else { + return "datetime" + } +} + +func (r *Mysql) TypeDateTimeTz(column schema.ColumnDefinition) string { + return r.TypeDateTime(column) +} + func (r *Mysql) TypeDecimal(column schema.ColumnDefinition) string { return fmt.Sprintf("decimal(%d, %d)", column.GetTotal(), column.GetPlaces()) } @@ -259,10 +286,6 @@ func (r *Mysql) TypeMediumText(column schema.ColumnDefinition) string { return "mediumtext" } -func (r *Mysql) TypeText(column schema.ColumnDefinition) string { - return "text" -} - func (r *Mysql) TypeSmallInteger(column schema.ColumnDefinition) string { return "smallint" } @@ -276,6 +299,45 @@ func (r *Mysql) TypeString(column schema.ColumnDefinition) string { return "varchar(255)" } +func (r *Mysql) TypeText(column schema.ColumnDefinition) string { + return "text" +} + +func (r *Mysql) TypeTime(column schema.ColumnDefinition) string { + if column.GetPrecision() > 0 { + return fmt.Sprintf("time(%d)", column.GetPrecision()) + } else { + return "time" + } +} + +func (r *Mysql) TypeTimeTz(column schema.ColumnDefinition) string { + return r.TypeTime(column) +} + +func (r *Mysql) TypeTimestamp(column schema.ColumnDefinition) string { + current := "CURRENT_TIMESTAMP" + if column.GetPrecision() > 0 { + current = fmt.Sprintf("CURRENT_TIMESTAMP(%d)", column.GetPrecision()) + } + if column.GetUseCurrent() { + column.Default(current) + } + if column.GetUseCurrentOnUpdate() { + column.OnUpdate(current) + } + + if column.GetPrecision() > 0 { + return fmt.Sprintf("timestamp(%d)", column.GetPrecision()) + } else { + return "timestamp" + } +} + +func (r *Mysql) TypeTimestampTz(column schema.ColumnDefinition) string { + return r.TypeTimestamp(column) +} + func (r *Mysql) TypeTinyInteger(column schema.ColumnDefinition) string { return "tinyint" } diff --git a/database/schema/grammars/postgres.go b/database/schema/grammars/postgres.go index cdfff45ba..bb4b07c01 100644 --- a/database/schema/grammars/postgres.go +++ b/database/schema/grammars/postgres.go @@ -221,6 +221,18 @@ func (r *Postgres) TypeChar(column schema.ColumnDefinition) string { return "char" } +func (r *Postgres) TypeDate(column schema.ColumnDefinition) string { + return "date" +} + +func (r *Postgres) TypeDateTime(column schema.ColumnDefinition) string { + return r.TypeTimestamp(column) +} + +func (r *Postgres) TypeDateTimeTz(column schema.ColumnDefinition) string { + return r.TypeTimestampTz(column) +} + func (r *Postgres) TypeDecimal(column schema.ColumnDefinition) string { return fmt.Sprintf("decimal(%d, %d)", column.GetTotal(), column.GetPlaces()) } @@ -270,10 +282,6 @@ func (r *Postgres) TypeMediumText(column schema.ColumnDefinition) string { return "text" } -func (r *Postgres) TypeText(column schema.ColumnDefinition) string { - return "text" -} - func (r *Postgres) TypeSmallInteger(column schema.ColumnDefinition) string { if column.GetAutoIncrement() { return "smallserial" @@ -291,6 +299,34 @@ func (r *Postgres) TypeString(column schema.ColumnDefinition) string { return "varchar" } +func (r *Postgres) TypeText(column schema.ColumnDefinition) string { + return "text" +} + +func (r *Postgres) TypeTime(column schema.ColumnDefinition) string { + return fmt.Sprintf("time(%d) without time zone", column.GetPrecision()) +} + +func (r *Postgres) TypeTimeTz(column schema.ColumnDefinition) string { + return fmt.Sprintf("time(%d) with time zone", column.GetPrecision()) +} + +func (r *Postgres) TypeTimestamp(column schema.ColumnDefinition) string { + if column.GetUseCurrent() { + column.Default("current_timestamp") + } + + return fmt.Sprintf("timestamp(%d) without time zone", column.GetPrecision()) +} + +func (r *Postgres) TypeTimestampTz(column schema.ColumnDefinition) string { + if column.GetUseCurrent() { + column.Default("current_timestamp") + } + + return fmt.Sprintf("timestamp(%d) with time zone", column.GetPrecision()) +} + func (r *Postgres) TypeTinyInteger(column schema.ColumnDefinition) string { return r.TypeSmallInteger(column) } diff --git a/database/schema/grammars/sqlite.go b/database/schema/grammars/sqlite.go index 881ebb6b9..33d71a139 100644 --- a/database/schema/grammars/sqlite.go +++ b/database/schema/grammars/sqlite.go @@ -169,6 +169,18 @@ func (r *Sqlite) TypeChar(column schema.ColumnDefinition) string { return "varchar" } +func (r *Sqlite) TypeDate(column schema.ColumnDefinition) string { + return "date" +} + +func (r *Sqlite) TypeDateTime(column schema.ColumnDefinition) string { + return r.TypeTimestamp(column) +} + +func (r *Sqlite) TypeDateTimeTz(column schema.ColumnDefinition) string { + return r.TypeDateTime(column) +} + func (r *Sqlite) TypeDecimal(column schema.ColumnDefinition) string { return "numeric" } @@ -209,24 +221,44 @@ func (r *Sqlite) TypeMediumText(column schema.ColumnDefinition) string { return "text" } +func (r *Sqlite) TypeSmallInteger(column schema.ColumnDefinition) string { + return "integer" +} + +func (r *Sqlite) TypeString(column schema.ColumnDefinition) string { + return "varchar" +} + func (r *Sqlite) TypeText(column schema.ColumnDefinition) string { return "text" } -func (r *Sqlite) TypeTinyInteger(column schema.ColumnDefinition) string { - return "integer" +func (r *Sqlite) TypeTime(column schema.ColumnDefinition) string { + return "time" } -func (r *Sqlite) TypeTinyText(column schema.ColumnDefinition) string { - return "text" +func (r *Sqlite) TypeTimeTz(column schema.ColumnDefinition) string { + return r.TypeTime(column) } -func (r *Sqlite) TypeSmallInteger(column schema.ColumnDefinition) string { +func (r *Sqlite) TypeTimestamp(column schema.ColumnDefinition) string { + if column.GetUseCurrent() { + column.Default("current_timestamp") + } + + return "datetime" +} + +func (r *Sqlite) TypeTimestampTz(column schema.ColumnDefinition) string { + return r.TypeTimestamp(column) +} + +func (r *Sqlite) TypeTinyInteger(column schema.ColumnDefinition) string { return "integer" } -func (r *Sqlite) TypeString(column schema.ColumnDefinition) string { - return "varchar" +func (r *Sqlite) TypeTinyText(column schema.ColumnDefinition) string { + return "text" } func (r *Sqlite) addForeignKeys(commands []*schema.Command) string { diff --git a/database/schema/grammars/sqlserver.go b/database/schema/grammars/sqlserver.go index e902a090b..d597a0f18 100644 --- a/database/schema/grammars/sqlserver.go +++ b/database/schema/grammars/sqlserver.go @@ -215,6 +215,18 @@ func (r *Sqlserver) TypeChar(column schema.ColumnDefinition) string { return fmt.Sprintf("nchar(%d)", column.GetLength()) } +func (r *Sqlserver) TypeDate(column schema.ColumnDefinition) string { + return "date" +} + +func (r *Sqlserver) TypeDateTime(column schema.ColumnDefinition) string { + return r.TypeTimestamp(column) +} + +func (r *Sqlserver) TypeDateTimeTz(column schema.ColumnDefinition) string { + return r.TypeTimestampTz(column) +} + func (r *Sqlserver) TypeDecimal(column schema.ColumnDefinition) string { return fmt.Sprintf("decimal(%d, %d)", column.GetTotal(), column.GetPlaces()) } @@ -260,10 +272,6 @@ func (r *Sqlserver) TypeMediumText(column schema.ColumnDefinition) string { return "nvarchar(max)" } -func (r *Sqlserver) TypeText(column schema.ColumnDefinition) string { - return "nvarchar(max)" -} - func (r *Sqlserver) TypeSmallInteger(column schema.ColumnDefinition) string { return "smallint" } @@ -277,6 +285,46 @@ func (r *Sqlserver) TypeString(column schema.ColumnDefinition) string { return "nvarchar(255)" } +func (r *Sqlserver) TypeText(column schema.ColumnDefinition) string { + return "nvarchar(max)" +} + +func (r *Sqlserver) TypeTime(column schema.ColumnDefinition) string { + if column.GetPrecision() > 0 { + return fmt.Sprintf("time(%d)", column.GetPrecision()) + } else { + return "time" + } +} + +func (r *Sqlserver) TypeTimeTz(column schema.ColumnDefinition) string { + return r.TypeTime(column) +} + +func (r *Sqlserver) TypeTimestamp(column schema.ColumnDefinition) string { + if column.GetUseCurrent() { + column.Default("current_timestamp") + } + + if column.GetPrecision() > 0 { + return fmt.Sprintf("datetime2(%d)", column.GetPrecision()) + } else { + return "datetime" + } +} + +func (r *Sqlserver) TypeTimestampTz(column schema.ColumnDefinition) string { + if column.GetUseCurrent() { + column.Default("current_timestamp") + } + + if column.GetPrecision() > 0 { + return fmt.Sprintf("datetimeoffset(%d)", column.GetPrecision()) + } else { + return "datetimeoffset" + } +} + func (r *Sqlserver) TypeTinyInteger(column schema.ColumnDefinition) string { return "tinyint" } diff --git a/database/schema/schema_test.go b/database/schema/schema_test.go index 3ed4c243c..59f5d7a7b 100644 --- a/database/schema/schema_test.go +++ b/database/schema/schema_test.go @@ -90,33 +90,33 @@ func (s *SchemaSuite) TestColumnMethods_Postgres() { s.Equal("character(255)", column.Type) s.Equal("bpchar", column.TypeName) } - //if column.Name == "date" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("date", column.Type) - // s.Equal("date", column.TypeName) - //} - //if column.Name == "date_time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date time column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "date_time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date time with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "date" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a date column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("date", column.Type) + s.Equal("date", column.TypeName) + } + if column.Name == "date_time" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a date time column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("timestamp(3) without time zone", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "date_time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a date time with time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("timestamp(3) with time zone", column.Type) + s.Equal("timestamptz", column.TypeName) + } if column.Name == "decimal" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -171,24 +171,24 @@ func (s *SchemaSuite) TestColumnMethods_Postgres() { s.Equal("integer", column.Type) s.Equal("int4", column.TypeName) } - //if column.Name == "deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "another_deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp(0) without time zone", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "another_deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp(0) with time zone", column.Type) + s.Equal("timestamptz", column.TypeName) + } if column.Name == "string" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -252,60 +252,60 @@ func (s *SchemaSuite) TestColumnMethods_Postgres() { s.Equal("character varying(255)", column.Type) s.Equal("varchar", column.TypeName) } - //if column.Name == "time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a time column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) without time zone", column.Type) - // s.Equal("time", column.TypeName) - //} - //if column.Name == "time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a time with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) with time zone", column.Type) - // s.Equal("timetz", column.TypeName) - //} - //if column.Name == "timestamp" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a timestamp without time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "timestamp_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a timestamp with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} - //if column.Name == "created_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "updated_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} + if column.Name == "time" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a time column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time(2) without time zone", column.Type) + s.Equal("time", column.TypeName) + } + if column.Name == "time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a time with time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time(2) with time zone", column.Type) + s.Equal("timetz", column.TypeName) + } + if column.Name == "timestamp" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a timestamp without time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("timestamp(2) without time zone", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "timestamp_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a timestamp with time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("timestamp(2) with time zone", column.Type) + s.Equal("timestamptz", column.TypeName) + } + if column.Name == "created_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp(2) without time zone", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "updated_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp(2) without time zone", column.Type) + s.Equal("timestamp", column.TypeName) + } if column.Name == "unsigned_integer" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -355,33 +355,27 @@ func (s *SchemaSuite) TestColumnMethods_Sqlite() { s.False(column.Nullable) s.Equal("varchar", column.Type) } - //if column.Name == "date" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("date", column.Type) - // s.Equal("date", column.TypeName) - //} - //if column.Name == "date_time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date time column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "date_time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date time with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "date" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("date", column.Type) + } + if column.Name == "date_time" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime", column.Type) + } + if column.Name == "date_time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime", column.Type) + } if column.Name == "decimal" { s.False(column.Autoincrement) s.Empty(column.Comment) @@ -424,24 +418,20 @@ func (s *SchemaSuite) TestColumnMethods_Sqlite() { s.False(column.Nullable) s.Equal("integer", column.Type) } - //if column.Name == "deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "another_deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime", column.Type) + } + if column.Name == "another_deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime", column.Type) + } if column.Name == "string" { s.False(column.Autoincrement) s.Empty(column.Comment) @@ -491,60 +481,48 @@ func (s *SchemaSuite) TestColumnMethods_Sqlite() { s.False(column.Nullable) s.Equal("text", column.Type) } - //if column.Name == "time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a time column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) without time zone", column.Type) - // s.Equal("time", column.TypeName) - //} - //if column.Name == "time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a time with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) with time zone", column.Type) - // s.Equal("timetz", column.TypeName) - //} - //if column.Name == "timestamp" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a timestamp without time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "timestamp_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a timestamp with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} - //if column.Name == "created_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "updated_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} + if column.Name == "time" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time", column.Type) + } + if column.Name == "time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time", column.Type) + } + if column.Name == "timestamp" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime", column.Type) + } + if column.Name == "timestamp_tz" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime", column.Type) + } + if column.Name == "created_at" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime", column.Type) + } + if column.Name == "updated_at" { + s.False(column.Autoincrement) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime", column.Type) + } if column.Name == "unsigned_integer" { s.False(column.Autoincrement) s.Empty(column.Comment) @@ -594,33 +572,33 @@ func (s *SchemaSuite) TestColumnMethods_Mysql() { s.Equal("char(255)", column.Type) s.Equal("char", column.TypeName) } - //if column.Name == "date" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("date", column.Type) - // s.Equal("date", column.TypeName) - //} - //if column.Name == "date_time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date time column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "date_time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a date time with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "date" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a date column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("date", column.Type) + s.Equal("date", column.TypeName) + } + if column.Name == "date_time" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a date time column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime(3)", column.Type) + s.Equal("datetime", column.TypeName) + } + if column.Name == "date_time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a date time with time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime(3)", column.Type) + s.Equal("datetime", column.TypeName) + } if column.Name == "decimal" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -675,24 +653,24 @@ func (s *SchemaSuite) TestColumnMethods_Mysql() { s.Equal("int", column.Type) s.Equal("int", column.TypeName) } - //if column.Name == "deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "another_deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "another_deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp", column.Type) + s.Equal("timestamp", column.TypeName) + } if column.Name == "string" { s.False(column.Autoincrement) s.Equal("utf8mb4_0900_ai_ci", column.Collation) @@ -756,60 +734,60 @@ func (s *SchemaSuite) TestColumnMethods_Mysql() { s.Equal("tinytext", column.Type) s.Equal("tinytext", column.TypeName) } - //if column.Name == "time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a time column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) without time zone", column.Type) - // s.Equal("time", column.TypeName) - //} - //if column.Name == "time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a time with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) with time zone", column.Type) - // s.Equal("timetz", column.TypeName) - //} - //if column.Name == "timestamp" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a timestamp without time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "timestamp_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Equal("This is a timestamp with time zone column", column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} - //if column.Name == "created_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "updated_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} + if column.Name == "time" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a time column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time(2)", column.Type) + s.Equal("time", column.TypeName) + } + if column.Name == "time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a time with time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time(2)", column.Type) + s.Equal("time", column.TypeName) + } + if column.Name == "timestamp" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a timestamp without time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("timestamp(2)", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "timestamp_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Equal("This is a timestamp with time zone column", column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("timestamp(2)", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "created_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp(2)", column.Type) + s.Equal("timestamp", column.TypeName) + } + if column.Name == "updated_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("timestamp(2)", column.Type) + s.Equal("timestamp", column.TypeName) + } if column.Name == "unsigned_integer" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -863,33 +841,33 @@ func (s *SchemaSuite) TestColumnMethods_Sqlserver() { s.Equal("nchar(510)", column.Type) s.Equal("nchar", column.TypeName) } - //if column.Name == "date" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("date", column.Type) - // s.Equal("date", column.TypeName) - //} - //if column.Name == "date_time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "date_time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(3) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "date" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("date", column.Type) + s.Equal("date", column.TypeName) + } + if column.Name == "date_time" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime2(23)", column.Type) + s.Equal("datetime2", column.TypeName) + } + if column.Name == "date_time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetimeoffset(30)", column.Type) + s.Equal("datetimeoffset", column.TypeName) + } if column.Name == "decimal" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -944,24 +922,24 @@ func (s *SchemaSuite) TestColumnMethods_Sqlserver() { s.Equal("int", column.Type) s.Equal("int", column.TypeName) } - //if column.Name == "deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "another_deleted_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(0) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} + if column.Name == "deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime", column.Type) + s.Equal("datetime", column.TypeName) + } + if column.Name == "another_deleted_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetimeoffset(34)", column.Type) + s.Equal("datetimeoffset", column.TypeName) + } if column.Name == "string" { s.False(column.Autoincrement) s.Equal("SQL_Latin1_General_CP1_CI_AS", column.Collation) @@ -1025,60 +1003,60 @@ func (s *SchemaSuite) TestColumnMethods_Sqlserver() { s.Equal("nvarchar(510)", column.Type) s.Equal("nvarchar", column.TypeName) } - //if column.Name == "time" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) without time zone", column.Type) - // s.Equal("time", column.TypeName) - //} - //if column.Name == "time_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("time(2) with time zone", column.Type) - // s.Equal("timetz", column.TypeName) - //} - //if column.Name == "timestamp" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "timestamp_tz" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.False(column.Nullable) - // s.Equal("timestamp(2) with time zone", column.Type) - // s.Equal("timestamptz", column.TypeName) - //} - //if column.Name == "created_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} - //if column.Name == "updated_at" { - // s.False(column.Autoincrement) - // s.Empty(column.Collation) - // s.Empty(column.Comment) - // s.Empty(column.Default) - // s.True(column.Nullable) - // s.Equal("timestamp(2) without time zone", column.Type) - // s.Equal("timestamp", column.TypeName) - //} + if column.Name == "time" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time(11)", column.Type) + s.Equal("time", column.TypeName) + } + if column.Name == "time_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("time(11)", column.Type) + s.Equal("time", column.TypeName) + } + if column.Name == "timestamp" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetime2(22)", column.Type) + s.Equal("datetime2", column.TypeName) + } + if column.Name == "timestamp_tz" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.False(column.Nullable) + s.Equal("datetimeoffset(29)", column.Type) + s.Equal("datetimeoffset", column.TypeName) + } + if column.Name == "created_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime2(22)", column.Type) + s.Equal("datetime2", column.TypeName) + } + if column.Name == "updated_at" { + s.False(column.Autoincrement) + s.Empty(column.Collation) + s.Empty(column.Comment) + s.Empty(column.Default) + s.True(column.Nullable) + s.Equal("datetime2(22)", column.Type) + s.Equal("datetime2", column.TypeName) + } if column.Name == "unsigned_integer" { s.False(column.Autoincrement) s.Empty(column.Collation) @@ -1631,17 +1609,17 @@ func (s *SchemaSuite) createTableAndAssertColumnsForColumnMethods(schema contrac err := schema.Create(table, func(table contractsschema.Blueprint) { table.BigInteger("big_integer").Comment("This is a big_integer column") table.Char("char").Comment("This is a char column") - //table.Date("date").Comment("This is a date column") - //table.DateTime("date_time", 3).Comment("This is a date time column") - //table.DateTimeTz("date_time_tz", 3).Comment("This is a date time with time zone column") + table.Date("date").Comment("This is a date column") + table.DateTime("date_time", 3).Comment("This is a date time column") + table.DateTimeTz("date_time_tz", 3).Comment("This is a date time with time zone column") table.Decimal("decimal").Places(1).Total(4).Comment("This is a decimal column") table.Double("double").Comment("This is a double column") table.Enum("enum", []string{"a", "b", "c"}).Comment("This is a enum column") table.Float("float", 2).Comment("This is a float column") table.ID().Comment("This is a id column") table.Integer("integer").Comment("This is a integer column") - //table.SoftDeletes() - //table.SoftDeletesTz("another_deleted_at") + table.SoftDeletes() + table.SoftDeletesTz("another_deleted_at") table.String("string").Comment("This is a string column") table.Json("json").Comment("This is a json column") table.Jsonb("jsonb").Comment("This is a jsonb column") @@ -1649,11 +1627,11 @@ func (s *SchemaSuite) createTableAndAssertColumnsForColumnMethods(schema contrac table.LongText("long_text").Comment("This is a long_text column") table.MediumText("medium_text").Comment("This is a medium_text column") table.TinyText("tiny_text").Comment("This is a tiny_text column") - //table.Time("time", 2).Comment("This is a time column") - //table.TimeTz("time_tz", 2).Comment("This is a time with time zone column") - //table.Timestamp("timestamp", 2).Comment("This is a timestamp without time zone column") - //table.TimestampTz("timestamp_tz", 2).Comment("This is a timestamp with time zone column") - //table.Timestamps(2) + table.Time("time", 2).Comment("This is a time column") + table.TimeTz("time_tz", 2).Comment("This is a time with time zone column") + table.Timestamp("timestamp", 2).Comment("This is a timestamp without time zone column") + table.TimestampTz("timestamp_tz", 2).Comment("This is a timestamp with time zone column") + table.Timestamps(2) table.UnsignedInteger("unsigned_integer").Comment("This is a unsigned_integer column") table.UnsignedBigInteger("unsigned_big_integer").Comment("This is a unsigned_big_integer column") }) @@ -1665,19 +1643,20 @@ func (s *SchemaSuite) createTableAndAssertColumnsForColumnMethods(schema contrac columnListing := schema.GetColumnListing(table) - s.Equal(17, len(columnListing)) + s.Equal(28, len(columnListing)) s.Contains(columnListing, "big_integer") s.Contains(columnListing, "char") - //s.Contains(columnListing, "date") - //s.Contains(columnListing, "date_time") - //s.Contains(columnListing, "date_time_tz") + s.Contains(columnListing, "date") + s.Contains(columnListing, "date_time") + s.Contains(columnListing, "date_time_tz") s.Contains(columnListing, "decimal") s.Contains(columnListing, "double") s.Contains(columnListing, "enum") + s.Contains(columnListing, "float") s.Contains(columnListing, "id") s.Contains(columnListing, "integer") - //s.Contains(columnListing, "deleted_at") - //s.Contains(columnListing, "another_deleted_at") + s.Contains(columnListing, "deleted_at") + s.Contains(columnListing, "another_deleted_at") s.Contains(columnListing, "string") s.Contains(columnListing, "json") s.Contains(columnListing, "jsonb") @@ -1685,13 +1664,12 @@ func (s *SchemaSuite) createTableAndAssertColumnsForColumnMethods(schema contrac s.Contains(columnListing, "long_text") s.Contains(columnListing, "medium_text") s.Contains(columnListing, "tiny_text") - //s.Contains(columnListing, "time") - //s.Contains(columnListing, "time_tz") - //s.Contains(columnListing, "timestamp") - //s.Contains(columnListing, "timestamp_tz") - //s.Contains(columnListing, "created_at") - //s.Contains(columnListing, "updated_at") + s.Contains(columnListing, "time") + s.Contains(columnListing, "time_tz") + s.Contains(columnListing, "timestamp") + s.Contains(columnListing, "timestamp_tz") + s.Contains(columnListing, "created_at") + s.Contains(columnListing, "updated_at") s.Contains(columnListing, "unsigned_integer") s.Contains(columnListing, "unsigned_big_integer") - } diff --git a/mocks/database/schema/Blueprint.go b/mocks/database/schema/Blueprint.go index 708221df7..550b74025 100644 --- a/mocks/database/schema/Blueprint.go +++ b/mocks/database/schema/Blueprint.go @@ -259,6 +259,180 @@ func (_c *Blueprint_Create_Call) RunAndReturn(run func()) *Blueprint_Create_Call return _c } +// Date provides a mock function with given fields: column +func (_m *Blueprint) Date(column string) schema.ColumnDefinition { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for Date") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string) schema.ColumnDefinition); ok { + r0 = rf(column) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_Date_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Date' +type Blueprint_Date_Call struct { + *mock.Call +} + +// Date is a helper method to define mock.On call +// - column string +func (_e *Blueprint_Expecter) Date(column interface{}) *Blueprint_Date_Call { + return &Blueprint_Date_Call{Call: _e.mock.On("Date", column)} +} + +func (_c *Blueprint_Date_Call) Run(run func(column string)) *Blueprint_Date_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Blueprint_Date_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_Date_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_Date_Call) RunAndReturn(run func(string) schema.ColumnDefinition) *Blueprint_Date_Call { + _c.Call.Return(run) + return _c +} + +// DateTime provides a mock function with given fields: column, precision +func (_m *Blueprint) DateTime(column string, precision ...int) schema.ColumnDefinition { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DateTime") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string, ...int) schema.ColumnDefinition); ok { + r0 = rf(column, precision...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_DateTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DateTime' +type Blueprint_DateTime_Call struct { + *mock.Call +} + +// DateTime is a helper method to define mock.On call +// - column string +// - precision ...int +func (_e *Blueprint_Expecter) DateTime(column interface{}, precision ...interface{}) *Blueprint_DateTime_Call { + return &Blueprint_DateTime_Call{Call: _e.mock.On("DateTime", + append([]interface{}{column}, precision...)...)} +} + +func (_c *Blueprint_DateTime_Call) Run(run func(column string, precision ...int)) *Blueprint_DateTime_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_DateTime_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_DateTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_DateTime_Call) RunAndReturn(run func(string, ...int) schema.ColumnDefinition) *Blueprint_DateTime_Call { + _c.Call.Return(run) + return _c +} + +// DateTimeTz provides a mock function with given fields: column, precision +func (_m *Blueprint) DateTimeTz(column string, precision ...int) schema.ColumnDefinition { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DateTimeTz") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string, ...int) schema.ColumnDefinition); ok { + r0 = rf(column, precision...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_DateTimeTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DateTimeTz' +type Blueprint_DateTimeTz_Call struct { + *mock.Call +} + +// DateTimeTz is a helper method to define mock.On call +// - column string +// - precision ...int +func (_e *Blueprint_Expecter) DateTimeTz(column interface{}, precision ...interface{}) *Blueprint_DateTimeTz_Call { + return &Blueprint_DateTimeTz_Call{Call: _e.mock.On("DateTimeTz", + append([]interface{}{column}, precision...)...)} +} + +func (_c *Blueprint_DateTimeTz_Call) Run(run func(column string, precision ...int)) *Blueprint_DateTimeTz_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_DateTimeTz_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_DateTimeTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_DateTimeTz_Call) RunAndReturn(run func(string, ...int) schema.ColumnDefinition) *Blueprint_DateTimeTz_Call { + _c.Call.Return(run) + return _c +} + // Decimal provides a mock function with given fields: column func (_m *Blueprint) Decimal(column string) schema.ColumnDefinition { ret := _m.Called(column) @@ -1474,6 +1648,128 @@ func (_c *Blueprint_SmallInteger_Call) RunAndReturn(run func(string) schema.Colu return _c } +// SoftDeletes provides a mock function with given fields: column +func (_m *Blueprint) SoftDeletes(column ...string) schema.ColumnDefinition { + _va := make([]interface{}, len(column)) + for _i := range column { + _va[_i] = column[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for SoftDeletes") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(...string) schema.ColumnDefinition); ok { + r0 = rf(column...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_SoftDeletes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SoftDeletes' +type Blueprint_SoftDeletes_Call struct { + *mock.Call +} + +// SoftDeletes is a helper method to define mock.On call +// - column ...string +func (_e *Blueprint_Expecter) SoftDeletes(column ...interface{}) *Blueprint_SoftDeletes_Call { + return &Blueprint_SoftDeletes_Call{Call: _e.mock.On("SoftDeletes", + append([]interface{}{}, column...)...)} +} + +func (_c *Blueprint_SoftDeletes_Call) Run(run func(column ...string)) *Blueprint_SoftDeletes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]string, len(args)-0) + for i, a := range args[0:] { + if a != nil { + variadicArgs[i] = a.(string) + } + } + run(variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_SoftDeletes_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_SoftDeletes_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_SoftDeletes_Call) RunAndReturn(run func(...string) schema.ColumnDefinition) *Blueprint_SoftDeletes_Call { + _c.Call.Return(run) + return _c +} + +// SoftDeletesTz provides a mock function with given fields: column +func (_m *Blueprint) SoftDeletesTz(column ...string) schema.ColumnDefinition { + _va := make([]interface{}, len(column)) + for _i := range column { + _va[_i] = column[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for SoftDeletesTz") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(...string) schema.ColumnDefinition); ok { + r0 = rf(column...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_SoftDeletesTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SoftDeletesTz' +type Blueprint_SoftDeletesTz_Call struct { + *mock.Call +} + +// SoftDeletesTz is a helper method to define mock.On call +// - column ...string +func (_e *Blueprint_Expecter) SoftDeletesTz(column ...interface{}) *Blueprint_SoftDeletesTz_Call { + return &Blueprint_SoftDeletesTz_Call{Call: _e.mock.On("SoftDeletesTz", + append([]interface{}{}, column...)...)} +} + +func (_c *Blueprint_SoftDeletesTz_Call) Run(run func(column ...string)) *Blueprint_SoftDeletesTz_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]string, len(args)-0) + for i, a := range args[0:] { + if a != nil { + variadicArgs[i] = a.(string) + } + } + run(variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_SoftDeletesTz_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_SoftDeletesTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_SoftDeletesTz_Call) RunAndReturn(run func(...string) schema.ColumnDefinition) *Blueprint_SoftDeletesTz_Call { + _c.Call.Return(run) + return _c +} + // String provides a mock function with given fields: column, length func (_m *Blueprint) String(column string, length ...int) schema.ColumnDefinition { _va := make([]interface{}, len(length)) @@ -1585,6 +1881,350 @@ func (_c *Blueprint_Text_Call) RunAndReturn(run func(string) schema.ColumnDefini return _c } +// Time provides a mock function with given fields: column, precision +func (_m *Blueprint) Time(column string, precision ...int) schema.ColumnDefinition { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for Time") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string, ...int) schema.ColumnDefinition); ok { + r0 = rf(column, precision...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_Time_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Time' +type Blueprint_Time_Call struct { + *mock.Call +} + +// Time is a helper method to define mock.On call +// - column string +// - precision ...int +func (_e *Blueprint_Expecter) Time(column interface{}, precision ...interface{}) *Blueprint_Time_Call { + return &Blueprint_Time_Call{Call: _e.mock.On("Time", + append([]interface{}{column}, precision...)...)} +} + +func (_c *Blueprint_Time_Call) Run(run func(column string, precision ...int)) *Blueprint_Time_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_Time_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_Time_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_Time_Call) RunAndReturn(run func(string, ...int) schema.ColumnDefinition) *Blueprint_Time_Call { + _c.Call.Return(run) + return _c +} + +// TimeTz provides a mock function with given fields: column, precision +func (_m *Blueprint) TimeTz(column string, precision ...int) schema.ColumnDefinition { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TimeTz") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string, ...int) schema.ColumnDefinition); ok { + r0 = rf(column, precision...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_TimeTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TimeTz' +type Blueprint_TimeTz_Call struct { + *mock.Call +} + +// TimeTz is a helper method to define mock.On call +// - column string +// - precision ...int +func (_e *Blueprint_Expecter) TimeTz(column interface{}, precision ...interface{}) *Blueprint_TimeTz_Call { + return &Blueprint_TimeTz_Call{Call: _e.mock.On("TimeTz", + append([]interface{}{column}, precision...)...)} +} + +func (_c *Blueprint_TimeTz_Call) Run(run func(column string, precision ...int)) *Blueprint_TimeTz_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_TimeTz_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_TimeTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_TimeTz_Call) RunAndReturn(run func(string, ...int) schema.ColumnDefinition) *Blueprint_TimeTz_Call { + _c.Call.Return(run) + return _c +} + +// Timestamp provides a mock function with given fields: column, precision +func (_m *Blueprint) Timestamp(column string, precision ...int) schema.ColumnDefinition { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for Timestamp") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string, ...int) schema.ColumnDefinition); ok { + r0 = rf(column, precision...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_Timestamp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Timestamp' +type Blueprint_Timestamp_Call struct { + *mock.Call +} + +// Timestamp is a helper method to define mock.On call +// - column string +// - precision ...int +func (_e *Blueprint_Expecter) Timestamp(column interface{}, precision ...interface{}) *Blueprint_Timestamp_Call { + return &Blueprint_Timestamp_Call{Call: _e.mock.On("Timestamp", + append([]interface{}{column}, precision...)...)} +} + +func (_c *Blueprint_Timestamp_Call) Run(run func(column string, precision ...int)) *Blueprint_Timestamp_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_Timestamp_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_Timestamp_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_Timestamp_Call) RunAndReturn(run func(string, ...int) schema.ColumnDefinition) *Blueprint_Timestamp_Call { + _c.Call.Return(run) + return _c +} + +// TimestampTz provides a mock function with given fields: column, precision +func (_m *Blueprint) TimestampTz(column string, precision ...int) schema.ColumnDefinition { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TimestampTz") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string, ...int) schema.ColumnDefinition); ok { + r0 = rf(column, precision...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// Blueprint_TimestampTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TimestampTz' +type Blueprint_TimestampTz_Call struct { + *mock.Call +} + +// TimestampTz is a helper method to define mock.On call +// - column string +// - precision ...int +func (_e *Blueprint_Expecter) TimestampTz(column interface{}, precision ...interface{}) *Blueprint_TimestampTz_Call { + return &Blueprint_TimestampTz_Call{Call: _e.mock.On("TimestampTz", + append([]interface{}{column}, precision...)...)} +} + +func (_c *Blueprint_TimestampTz_Call) Run(run func(column string, precision ...int)) *Blueprint_TimestampTz_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_TimestampTz_Call) Return(_a0 schema.ColumnDefinition) *Blueprint_TimestampTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Blueprint_TimestampTz_Call) RunAndReturn(run func(string, ...int) schema.ColumnDefinition) *Blueprint_TimestampTz_Call { + _c.Call.Return(run) + return _c +} + +// Timestamps provides a mock function with given fields: precision +func (_m *Blueprint) Timestamps(precision ...int) { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + _m.Called(_ca...) +} + +// Blueprint_Timestamps_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Timestamps' +type Blueprint_Timestamps_Call struct { + *mock.Call +} + +// Timestamps is a helper method to define mock.On call +// - precision ...int +func (_e *Blueprint_Expecter) Timestamps(precision ...interface{}) *Blueprint_Timestamps_Call { + return &Blueprint_Timestamps_Call{Call: _e.mock.On("Timestamps", + append([]interface{}{}, precision...)...)} +} + +func (_c *Blueprint_Timestamps_Call) Run(run func(precision ...int)) *Blueprint_Timestamps_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-0) + for i, a := range args[0:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_Timestamps_Call) Return() *Blueprint_Timestamps_Call { + _c.Call.Return() + return _c +} + +func (_c *Blueprint_Timestamps_Call) RunAndReturn(run func(...int)) *Blueprint_Timestamps_Call { + _c.Call.Return(run) + return _c +} + +// TimestampsTz provides a mock function with given fields: precision +func (_m *Blueprint) TimestampsTz(precision ...int) { + _va := make([]interface{}, len(precision)) + for _i := range precision { + _va[_i] = precision[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + _m.Called(_ca...) +} + +// Blueprint_TimestampsTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TimestampsTz' +type Blueprint_TimestampsTz_Call struct { + *mock.Call +} + +// TimestampsTz is a helper method to define mock.On call +// - precision ...int +func (_e *Blueprint_Expecter) TimestampsTz(precision ...interface{}) *Blueprint_TimestampsTz_Call { + return &Blueprint_TimestampsTz_Call{Call: _e.mock.On("TimestampsTz", + append([]interface{}{}, precision...)...)} +} + +func (_c *Blueprint_TimestampsTz_Call) Run(run func(precision ...int)) *Blueprint_TimestampsTz_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]int, len(args)-0) + for i, a := range args[0:] { + if a != nil { + variadicArgs[i] = a.(int) + } + } + run(variadicArgs...) + }) + return _c +} + +func (_c *Blueprint_TimestampsTz_Call) Return() *Blueprint_TimestampsTz_Call { + _c.Call.Return() + return _c +} + +func (_c *Blueprint_TimestampsTz_Call) RunAndReturn(run func(...int)) *Blueprint_TimestampsTz_Call { + _c.Call.Return(run) + return _c +} + // TinyIncrements provides a mock function with given fields: column func (_m *Blueprint) TinyIncrements(column string) schema.ColumnDefinition { ret := _m.Called(column) diff --git a/mocks/database/schema/ColumnDefinition.go b/mocks/database/schema/ColumnDefinition.go index 653dc650c..ad061d32c 100644 --- a/mocks/database/schema/ColumnDefinition.go +++ b/mocks/database/schema/ColumnDefinition.go @@ -115,6 +115,54 @@ func (_c *ColumnDefinition_Comment_Call) RunAndReturn(run func(string) schema.Co return _c } +// Default provides a mock function with given fields: def +func (_m *ColumnDefinition) Default(def any) schema.ColumnDefinition { + ret := _m.Called(def) + + if len(ret) == 0 { + panic("no return value specified for Default") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(any) schema.ColumnDefinition); ok { + r0 = rf(def) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// ColumnDefinition_Default_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Default' +type ColumnDefinition_Default_Call struct { + *mock.Call +} + +// Default is a helper method to define mock.On call +// - def any +func (_e *ColumnDefinition_Expecter) Default(def interface{}) *ColumnDefinition_Default_Call { + return &ColumnDefinition_Default_Call{Call: _e.mock.On("Default", def)} +} + +func (_c *ColumnDefinition_Default_Call) Run(run func(def any)) *ColumnDefinition_Default_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(any)) + }) + return _c +} + +func (_c *ColumnDefinition_Default_Call) Return(_a0 schema.ColumnDefinition) *ColumnDefinition_Default_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ColumnDefinition_Default_Call) RunAndReturn(run func(any) schema.ColumnDefinition) *ColumnDefinition_Default_Call { + _c.Call.Return(run) + return _c +} + // GetAllowed provides a mock function with given fields: func (_m *ColumnDefinition) GetAllowed() []string { ret := _m.Called() @@ -614,6 +662,96 @@ func (_c *ColumnDefinition_GetType_Call) RunAndReturn(run func() string) *Column return _c } +// GetUseCurrent provides a mock function with given fields: +func (_m *ColumnDefinition) GetUseCurrent() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetUseCurrent") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// ColumnDefinition_GetUseCurrent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUseCurrent' +type ColumnDefinition_GetUseCurrent_Call struct { + *mock.Call +} + +// GetUseCurrent is a helper method to define mock.On call +func (_e *ColumnDefinition_Expecter) GetUseCurrent() *ColumnDefinition_GetUseCurrent_Call { + return &ColumnDefinition_GetUseCurrent_Call{Call: _e.mock.On("GetUseCurrent")} +} + +func (_c *ColumnDefinition_GetUseCurrent_Call) Run(run func()) *ColumnDefinition_GetUseCurrent_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ColumnDefinition_GetUseCurrent_Call) Return(_a0 bool) *ColumnDefinition_GetUseCurrent_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ColumnDefinition_GetUseCurrent_Call) RunAndReturn(run func() bool) *ColumnDefinition_GetUseCurrent_Call { + _c.Call.Return(run) + return _c +} + +// GetUseCurrentOnUpdate provides a mock function with given fields: +func (_m *ColumnDefinition) GetUseCurrentOnUpdate() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetUseCurrentOnUpdate") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// ColumnDefinition_GetUseCurrentOnUpdate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUseCurrentOnUpdate' +type ColumnDefinition_GetUseCurrentOnUpdate_Call struct { + *mock.Call +} + +// GetUseCurrentOnUpdate is a helper method to define mock.On call +func (_e *ColumnDefinition_Expecter) GetUseCurrentOnUpdate() *ColumnDefinition_GetUseCurrentOnUpdate_Call { + return &ColumnDefinition_GetUseCurrentOnUpdate_Call{Call: _e.mock.On("GetUseCurrentOnUpdate")} +} + +func (_c *ColumnDefinition_GetUseCurrentOnUpdate_Call) Run(run func()) *ColumnDefinition_GetUseCurrentOnUpdate_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ColumnDefinition_GetUseCurrentOnUpdate_Call) Return(_a0 bool) *ColumnDefinition_GetUseCurrentOnUpdate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ColumnDefinition_GetUseCurrentOnUpdate_Call) RunAndReturn(run func() bool) *ColumnDefinition_GetUseCurrentOnUpdate_Call { + _c.Call.Return(run) + return _c +} + // IsSetComment provides a mock function with given fields: func (_m *ColumnDefinition) IsSetComment() bool { ret := _m.Called() @@ -706,6 +844,54 @@ func (_c *ColumnDefinition_Nullable_Call) RunAndReturn(run func() schema.ColumnD return _c } +// OnUpdate provides a mock function with given fields: value +func (_m *ColumnDefinition) OnUpdate(value string) schema.ColumnDefinition { + ret := _m.Called(value) + + if len(ret) == 0 { + panic("no return value specified for OnUpdate") + } + + var r0 schema.ColumnDefinition + if rf, ok := ret.Get(0).(func(string) schema.ColumnDefinition); ok { + r0 = rf(value) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(schema.ColumnDefinition) + } + } + + return r0 +} + +// ColumnDefinition_OnUpdate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnUpdate' +type ColumnDefinition_OnUpdate_Call struct { + *mock.Call +} + +// OnUpdate is a helper method to define mock.On call +// - value string +func (_e *ColumnDefinition_Expecter) OnUpdate(value interface{}) *ColumnDefinition_OnUpdate_Call { + return &ColumnDefinition_OnUpdate_Call{Call: _e.mock.On("OnUpdate", value)} +} + +func (_c *ColumnDefinition_OnUpdate_Call) Run(run func(value string)) *ColumnDefinition_OnUpdate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ColumnDefinition_OnUpdate_Call) Return(_a0 schema.ColumnDefinition) *ColumnDefinition_OnUpdate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ColumnDefinition_OnUpdate_Call) RunAndReturn(run func(string) schema.ColumnDefinition) *ColumnDefinition_OnUpdate_Call { + _c.Call.Return(run) + return _c +} + // Places provides a mock function with given fields: places func (_m *ColumnDefinition) Places(places int) schema.ColumnDefinition { ret := _m.Called(places) diff --git a/mocks/database/schema/Grammar.go b/mocks/database/schema/Grammar.go index 2bb626a7e..e51d79926 100644 --- a/mocks/database/schema/Grammar.go +++ b/mocks/database/schema/Grammar.go @@ -901,6 +901,144 @@ func (_c *Grammar_TypeChar_Call) RunAndReturn(run func(schema.ColumnDefinition) return _c } +// TypeDate provides a mock function with given fields: column +func (_m *Grammar) TypeDate(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeDate") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeDate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeDate' +type Grammar_TypeDate_Call struct { + *mock.Call +} + +// TypeDate is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeDate(column interface{}) *Grammar_TypeDate_Call { + return &Grammar_TypeDate_Call{Call: _e.mock.On("TypeDate", column)} +} + +func (_c *Grammar_TypeDate_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeDate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeDate_Call) Return(_a0 string) *Grammar_TypeDate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeDate_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeDate_Call { + _c.Call.Return(run) + return _c +} + +// TypeDateTime provides a mock function with given fields: column +func (_m *Grammar) TypeDateTime(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeDateTime") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeDateTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeDateTime' +type Grammar_TypeDateTime_Call struct { + *mock.Call +} + +// TypeDateTime is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeDateTime(column interface{}) *Grammar_TypeDateTime_Call { + return &Grammar_TypeDateTime_Call{Call: _e.mock.On("TypeDateTime", column)} +} + +func (_c *Grammar_TypeDateTime_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeDateTime_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeDateTime_Call) Return(_a0 string) *Grammar_TypeDateTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeDateTime_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeDateTime_Call { + _c.Call.Return(run) + return _c +} + +// TypeDateTimeTz provides a mock function with given fields: column +func (_m *Grammar) TypeDateTimeTz(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeDateTimeTz") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeDateTimeTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeDateTimeTz' +type Grammar_TypeDateTimeTz_Call struct { + *mock.Call +} + +// TypeDateTimeTz is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeDateTimeTz(column interface{}) *Grammar_TypeDateTimeTz_Call { + return &Grammar_TypeDateTimeTz_Call{Call: _e.mock.On("TypeDateTimeTz", column)} +} + +func (_c *Grammar_TypeDateTimeTz_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeDateTimeTz_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeDateTimeTz_Call) Return(_a0 string) *Grammar_TypeDateTimeTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeDateTimeTz_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeDateTimeTz_Call { + _c.Call.Return(run) + return _c +} + // TypeDecimal provides a mock function with given fields: column func (_m *Grammar) TypeDecimal(column schema.ColumnDefinition) string { ret := _m.Called(column) @@ -1499,6 +1637,190 @@ func (_c *Grammar_TypeText_Call) RunAndReturn(run func(schema.ColumnDefinition) return _c } +// TypeTime provides a mock function with given fields: column +func (_m *Grammar) TypeTime(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeTime") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeTime' +type Grammar_TypeTime_Call struct { + *mock.Call +} + +// TypeTime is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeTime(column interface{}) *Grammar_TypeTime_Call { + return &Grammar_TypeTime_Call{Call: _e.mock.On("TypeTime", column)} +} + +func (_c *Grammar_TypeTime_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeTime_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeTime_Call) Return(_a0 string) *Grammar_TypeTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeTime_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeTime_Call { + _c.Call.Return(run) + return _c +} + +// TypeTimeTz provides a mock function with given fields: column +func (_m *Grammar) TypeTimeTz(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeTimeTz") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeTimeTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeTimeTz' +type Grammar_TypeTimeTz_Call struct { + *mock.Call +} + +// TypeTimeTz is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeTimeTz(column interface{}) *Grammar_TypeTimeTz_Call { + return &Grammar_TypeTimeTz_Call{Call: _e.mock.On("TypeTimeTz", column)} +} + +func (_c *Grammar_TypeTimeTz_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeTimeTz_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeTimeTz_Call) Return(_a0 string) *Grammar_TypeTimeTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeTimeTz_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeTimeTz_Call { + _c.Call.Return(run) + return _c +} + +// TypeTimestamp provides a mock function with given fields: column +func (_m *Grammar) TypeTimestamp(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeTimestamp") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeTimestamp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeTimestamp' +type Grammar_TypeTimestamp_Call struct { + *mock.Call +} + +// TypeTimestamp is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeTimestamp(column interface{}) *Grammar_TypeTimestamp_Call { + return &Grammar_TypeTimestamp_Call{Call: _e.mock.On("TypeTimestamp", column)} +} + +func (_c *Grammar_TypeTimestamp_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeTimestamp_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeTimestamp_Call) Return(_a0 string) *Grammar_TypeTimestamp_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeTimestamp_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeTimestamp_Call { + _c.Call.Return(run) + return _c +} + +// TypeTimestampTz provides a mock function with given fields: column +func (_m *Grammar) TypeTimestampTz(column schema.ColumnDefinition) string { + ret := _m.Called(column) + + if len(ret) == 0 { + panic("no return value specified for TypeTimestampTz") + } + + var r0 string + if rf, ok := ret.Get(0).(func(schema.ColumnDefinition) string); ok { + r0 = rf(column) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Grammar_TypeTimestampTz_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeTimestampTz' +type Grammar_TypeTimestampTz_Call struct { + *mock.Call +} + +// TypeTimestampTz is a helper method to define mock.On call +// - column schema.ColumnDefinition +func (_e *Grammar_Expecter) TypeTimestampTz(column interface{}) *Grammar_TypeTimestampTz_Call { + return &Grammar_TypeTimestampTz_Call{Call: _e.mock.On("TypeTimestampTz", column)} +} + +func (_c *Grammar_TypeTimestampTz_Call) Run(run func(column schema.ColumnDefinition)) *Grammar_TypeTimestampTz_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(schema.ColumnDefinition)) + }) + return _c +} + +func (_c *Grammar_TypeTimestampTz_Call) Return(_a0 string) *Grammar_TypeTimestampTz_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Grammar_TypeTimestampTz_Call) RunAndReturn(run func(schema.ColumnDefinition) string) *Grammar_TypeTimestampTz_Call { + _c.Call.Return(run) + return _c +} + // TypeTinyInteger provides a mock function with given fields: column func (_m *Grammar) TypeTinyInteger(column schema.ColumnDefinition) string { ret := _m.Called(column)