schema

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewForeignKeyDefinition

func NewForeignKeyDefinition(command *schema.Command) schema.ForeignKeyDefinition

func NewIndexDefinition

func NewIndexDefinition(command *schema.Command) schema.IndexDefinition

func ValidateMigrationSignature added in v0.16.0

func ValidateMigrationSignature(signature string, format MigrationSignatureFormat) error

ValidateMigrationSignature validates that the migration signature follows the specified format Supported formats:

  • YYYY_MM_DD_HHMM_description (for datetime format)
  • YYYY_MM_DD_NNN_description (for date format)
  • unix_timestamp_description (for unix format)
  • custom (no prefix format restriction)

Business Logic: - Enforces maximum length of 255 characters - Rejects empty signatures - For "custom" format: only validates length and non-empty - For other formats: requires at least 5 underscore-separated parts (or 2 for unix) - Validates date part (YYYY_MM_DD) is a valid calendar date - Validates time part (HHMM) or sequence part (NNN) based on format - Validates description exists and is within length limits - Ensures lexicographical ordering by date/time

Types

type Blueprint

type Blueprint struct {
	// contains filtered or unexported fields
}

Blueprint represents a database table schema definition for migrations. It provides a fluent interface for defining table structure, including columns, indexes, foreign keys, and other schema elements. The blueprint is used by schema builders to generate database-specific SQL statements.

func NewBlueprint

func NewBlueprint(schema schema.Schema, prefix, table string) *Blueprint

NewBlueprint creates a new Blueprint instance for the specified schema, prefix, and table. The schema parameter provides database connection and grammar capabilities. The prefix is used to prefix table names (useful for multi-tenancy or namespacing). The table parameter specifies the name of the table to create or modify.

func (*Blueprint) BigIncrements

func (r *Blueprint) BigIncrements(column string) schema.ColumnDefinition

BigIncrements creates a new auto-incrementing big integer (bigint) column on the table. This is typically used as a primary key for tables that may have many records. The column will be unsigned and set to auto-increment.

func (*Blueprint) BigInteger

func (r *Blueprint) BigInteger(column string) schema.ColumnDefinition

BigInteger creates a new big integer (bigint) column on the table. Big integers can store values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

func (*Blueprint) Boolean

func (r *Blueprint) Boolean(column string) schema.ColumnDefinition

Boolean creates a new boolean column on the table. Boolean columns typically store true/false values, often represented as 0/1 in the database.

func (*Blueprint) Build

func (r *Blueprint) Build(query ormcontract.Query, grammar schema.Grammar) error

Build executes the schema blueprint against the database using the provided query and grammar. It converts all commands into SQL statements and executes them in sequence. Returns an error if any SQL statement fails to execute.

func (*Blueprint) Change

func (r *Blueprint) Change() schema.ColumnDefinition

Change modifies the most recently added column definition. This is used in table modification operations to alter an existing column's properties. Returns nil if no columns have been added to the blueprint.

func (*Blueprint) Char

func (r *Blueprint) Char(column string, length ...int) schema.ColumnDefinition

Char creates a new fixed-length character column on the table. The length parameter is optional; if not provided, it defaults to the DefaultStringLength constant. Char columns are faster than varchar but use fixed storage regardless of actual content length.

func (*Blueprint) Column

func (r *Blueprint) Column(column, ttype string) schema.ColumnDefinition

Column creates a new column of the specified type on the table. This is a generic method that allows adding any column type by specifying its type string. The ttype parameter should match a type recognized by the database grammar.

func (*Blueprint) Create

func (r *Blueprint) Create()

Create indicates that the blueprint should create a new table. This command is used when defining a new table structure in a migration.

func (*Blueprint) Date

func (r *Blueprint) Date(column string) schema.ColumnDefinition

Date creates a new date column on the table. Date columns store calendar dates (year, month, day) without time components.

func (*Blueprint) DateTime

func (r *Blueprint) DateTime(column string, precision ...int) schema.ColumnDefinition

DateTime creates a new datetime column on the table. The precision parameter is optional and specifies fractional seconds precision (0-6). DateTime columns store both date and time information.

func (*Blueprint) DateTimeTz

func (r *Blueprint) DateTimeTz(column string, precision ...int) schema.ColumnDefinition

DateTimeTz creates a new datetime with timezone column on the table. The precision parameter is optional and specifies fractional seconds precision (0-6). DateTimeTz columns store date, time, and timezone information.

func (*Blueprint) Decimal

func (r *Blueprint) Decimal(column string) schema.ColumnDefinition

Decimal creates a new decimal column on the table. Decimal columns are used for precise numeric calculations, such as monetary values. Use the methods on the returned ColumnDefinition to set precision and scale.

func (*Blueprint) Double

func (r *Blueprint) Double(column string) schema.ColumnDefinition

Double creates a new double-precision floating-point column on the table. Double columns provide high precision for floating-point numbers.

func (*Blueprint) Drop

func (r *Blueprint) Drop()

Drop indicates that the blueprint should drop the table. This command permanently removes the table and all its data from the database.

func (*Blueprint) DropColumn

func (r *Blueprint) DropColumn(column ...string)

DropColumn removes one or more columns from the table. Multiple column names can be specified to drop several columns at once.

func (*Blueprint) DropForeign

func (r *Blueprint) DropForeign(column ...string)

DropForeign removes a foreign key constraint from the table. The column parameter specifies the column(s) that the foreign key constraint is based on. The foreign key name is automatically generated if not explicitly set.

func (*Blueprint) DropForeignByName

func (r *Blueprint) DropForeignByName(name string)

DropForeignByName removes a foreign key constraint by its name. This is useful when you need to drop a foreign key with a specific name.

func (*Blueprint) DropFullText

func (r *Blueprint) DropFullText(column ...string)

DropFullText removes a full-text index from the table. The column parameter specifies the column(s) that the full-text index is based on. The index name is automatically generated if not explicitly set.

func (*Blueprint) DropFullTextByName

func (r *Blueprint) DropFullTextByName(name string)

DropFullTextByName removes a full-text index by its name. This is useful when you need to drop a full-text index with a specific name.

func (*Blueprint) DropIfExists

func (r *Blueprint) DropIfExists()

DropIfExists indicates that the blueprint should drop the table if it exists. This command is safer than Drop as it won't fail if the table doesn't exist.

func (*Blueprint) DropIndex

func (r *Blueprint) DropIndex(column ...string)

DropIndex removes a regular index from the table. The column parameter specifies the column(s) that the index is based on. The index name is automatically generated if not explicitly set.

func (*Blueprint) DropIndexByName

func (r *Blueprint) DropIndexByName(name string)

DropIndexByName removes an index by its name. This is useful when you need to drop an index with a specific name.

func (*Blueprint) DropPrimary

func (r *Blueprint) DropPrimary(column ...string)

DropPrimary removes the primary key constraint from the table. The column parameter specifies the column(s) that make up the primary key.

func (*Blueprint) DropSoftDeletes

func (r *Blueprint) DropSoftDeletes(column ...string)

DropSoftDeletes removes the soft delete column from the table. If no column name is specified, it defaults to "soft_deleted_at". This is used to remove soft delete functionality from a table.

func (*Blueprint) DropSoftDeletesTz

func (r *Blueprint) DropSoftDeletesTz(column ...string)

DropSoftDeletesTz removes the soft delete with timezone column from the table. This is an alias for DropSoftDeletes as timezone handling is database-specific.

func (*Blueprint) DropTimestamps

func (r *Blueprint) DropTimestamps()

DropTimestamps removes the created_at and updated_at timestamp columns from the table. This is used to remove automatic timestamp tracking from a table.

func (*Blueprint) DropTimestampsTz

func (r *Blueprint) DropTimestampsTz()

DropTimestampsTz removes the timestamp with timezone columns from the table. This is an alias for DropTimestamps as timezone handling is database-specific.

func (*Blueprint) DropUnique

func (r *Blueprint) DropUnique(column ...string)

DropUnique removes a unique index from the table. The column parameter specifies the column(s) that the unique index is based on. The index name is automatically generated if not explicitly set.

func (*Blueprint) DropUniqueByName

func (r *Blueprint) DropUniqueByName(name string)

DropUniqueByName removes a unique index by its name. This is useful when you need to drop a unique index with a specific name.

func (*Blueprint) Enum

func (r *Blueprint) Enum(column string, allowed []any) schema.ColumnDefinition

Enum creates a new enum column on the table. The allowed parameter specifies the valid values for the enum. Enum columns restrict values to a predefined set of options.

func (*Blueprint) Float

func (r *Blueprint) Float(column string, precision ...int) schema.ColumnDefinition

Float creates a new float column on the table. The precision parameter is optional; if not provided, it defaults to 53 bits. Float columns are used for single-precision floating-point numbers.

func (*Blueprint) Foreign

func (r *Blueprint) Foreign(column ...string) schema.ForeignKeyDefinition

Foreign creates a new foreign key constraint on the table. The column parameter specifies the column(s) that reference another table. Returns a ForeignKeyDefinition that can be used to configure the constraint further.

func (*Blueprint) FullText

func (r *Blueprint) FullText(column ...string) schema.IndexDefinition

FullText creates a new full-text index on the table. The column parameter specifies the column(s) to include in the full-text index. Full-text indexes enable efficient text searching capabilities.

func (*Blueprint) Geometry added in v0.7.0

func (r *Blueprint) Geometry(column string) schema.ColumnDefinition

Geometry creates a new geometry column on the table. Geometry columns store spatial data such as points, lines, and polygons.

func (*Blueprint) GeometryCollection added in v0.7.0

func (r *Blueprint) GeometryCollection(column string) schema.ColumnDefinition

GeometryCollection creates a new geometry collection column on the table. Geometry collections can store multiple geometry objects in a single column.

func (*Blueprint) GetAddedColumns

func (r *Blueprint) GetAddedColumns() []schema.ColumnDefinition

GetAddedColumns returns all column definitions that have been added to this blueprint. This is useful for introspection or validation of the schema definition.

func (*Blueprint) GetCommands

func (r *Blueprint) GetCommands() []*schema.Command

GetCommands returns all schema commands that have been added to this blueprint. This includes create, drop, alter, and other schema operations.

func (*Blueprint) GetTableName

func (r *Blueprint) GetTableName() string

GetTableName returns the name of the table for this blueprint.

func (*Blueprint) HasCommand

func (r *Blueprint) HasCommand(command string) bool

HasCommand checks if a command of the specified type exists in this blueprint. This is useful for conditional logic based on the blueprint's state.

func (*Blueprint) ID

func (r *Blueprint) ID(column ...string) schema.ColumnDefinition

ID creates a new auto-incrementing big integer primary key column on the table. If no column name is specified, it defaults to "id". This is a convenience method for creating a standard primary key.

func (*Blueprint) Increments

func (r *Blueprint) Increments(column string) schema.ColumnDefinition

Increments creates a new auto-incrementing integer column on the table. This is an alias for IntegerIncrements.

func (*Blueprint) Index

func (r *Blueprint) Index(column ...string) schema.IndexDefinition

Index creates a new regular index on the table. The column parameter specifies the column(s) to include in the index. Returns an IndexDefinition that can be used to configure the index further.

func (*Blueprint) Integer

func (r *Blueprint) Integer(column string) schema.ColumnDefinition

Integer creates a new integer column on the table. Integer columns can store values from -2,147,483,648 to 2,147,483,647.

func (*Blueprint) IntegerIncrements

func (r *Blueprint) IntegerIncrements(column string) schema.ColumnDefinition

IntegerIncrements creates a new auto-incrementing integer column on the table. The column will be unsigned and set to auto-increment.

func (*Blueprint) Json

func (r *Blueprint) Json(column string) schema.ColumnDefinition

Json creates a new JSON column on the table. JSON columns store JSON data and provide JSON validation and querying capabilities.

func (*Blueprint) Jsonb

func (r *Blueprint) Jsonb(column string) schema.ColumnDefinition

Jsonb creates a new JSONB column on the table. JSONB is a binary JSON format that provides better performance for querying and indexing. This is primarily used in PostgreSQL databases.

func (*Blueprint) LineString added in v0.7.0

func (r *Blueprint) LineString(column string) schema.ColumnDefinition

LineString creates a new linestring column on the table. Linestrings store a sequence of points forming a line.

func (*Blueprint) LongText

func (r *Blueprint) LongText(column string) schema.ColumnDefinition

LongText creates a new long text column on the table. Long text columns can store large amounts of text data (up to 4GB in some databases).

func (*Blueprint) MediumIncrements

func (r *Blueprint) MediumIncrements(column string) schema.ColumnDefinition

MediumIncrements creates a new auto-incrementing medium integer column on the table. The column will be unsigned and set to auto-increment.

func (*Blueprint) MediumInteger

func (r *Blueprint) MediumInteger(column string) schema.ColumnDefinition

MediumInteger creates a new medium integer column on the table. Medium integers can store values from -8,388,608 to 8,388,607.

func (*Blueprint) MediumText

func (r *Blueprint) MediumText(column string) schema.ColumnDefinition

MediumText creates a new medium text column on the table. Medium text columns can store moderate amounts of text data (up to 16MB in some databases).

func (*Blueprint) MultiLineString added in v0.7.0

func (r *Blueprint) MultiLineString(column string) schema.ColumnDefinition

MultiLineString creates a new multilinestring column on the table. Multilinestrings store a collection of linestrings.

func (*Blueprint) MultiPoint added in v0.7.0

func (r *Blueprint) MultiPoint(column string) schema.ColumnDefinition

MultiPoint creates a new multipoint column on the table. Multipoints store a collection of points.

func (*Blueprint) MultiPolygon added in v0.7.0

func (r *Blueprint) MultiPolygon(column string) schema.ColumnDefinition

MultiPolygon creates a new multipolygon column on the table. Multipolygons store a collection of polygons.

func (*Blueprint) Point added in v0.7.0

func (r *Blueprint) Point(column string) schema.ColumnDefinition

Point creates a new point column on the table. Points store a single coordinate (x, y) in 2D space.

func (*Blueprint) Polygon added in v0.7.0

func (r *Blueprint) Polygon(column string) schema.ColumnDefinition

Polygon creates a new polygon column on the table. Polygons store a closed shape defined by a sequence of points.

func (*Blueprint) Primary

func (r *Blueprint) Primary(column ...string)

Primary creates a new primary key constraint on the table. The column parameter specifies the column(s) that make up the primary key. If no columns are specified, the most recently added column will be used.

func (*Blueprint) Rename

func (r *Blueprint) Rename(to string)

Rename indicates that the table should be renamed to the specified name. The to parameter specifies the new table name.

func (*Blueprint) RenameColumn

func (r *Blueprint) RenameColumn(from, to string)

RenameColumn renames a column from one name to another. The from parameter specifies the current column name. The to parameter specifies the new column name.

func (*Blueprint) RenameIndex

func (r *Blueprint) RenameIndex(from, to string)

RenameIndex renames an index from one name to another. The from parameter specifies the current index name. The to parameter specifies the new index name. This operation skips transaction wrapping due to SQLite limitations.

func (*Blueprint) SetTable

func (r *Blueprint) SetTable(name string)

SetTable changes the table name for this blueprint. This is useful when the table name needs to be modified after blueprint creation.

func (*Blueprint) ShortID added in v0.11.0

func (r *Blueprint) ShortID(column ...string) schema.ColumnDefinition

ShortID creates a new short string primary key column on the table. Suitable for client-generated short IDs (e.g., Crockford Base32).

func (*Blueprint) ShouldSkipTransaction added in v0.3.0

func (r *Blueprint) ShouldSkipTransaction() bool

ShouldSkipTransaction returns true if the blueprint should skip the transaction wrapper. This is used for SQLite-specific operations like RenameIndex that have issues with DDL in transactions.

func (*Blueprint) SkipTransaction added in v0.3.0

func (r *Blueprint) SkipTransaction()

SkipTransaction marks the blueprint to skip the transaction wrapper during build. This is primarily used for SQLite RenameIndex operations to avoid savepoint timeout issues.

func (*Blueprint) SmallIncrements

func (r *Blueprint) SmallIncrements(column string) schema.ColumnDefinition

SmallIncrements creates a new auto-incrementing small integer column on the table. The column will be unsigned and set to auto-increment.

func (*Blueprint) SmallInteger

func (r *Blueprint) SmallInteger(column string) schema.ColumnDefinition

SmallInteger creates a new small integer column on the table. Small integers can store values from -32,768 to 32,767.

func (*Blueprint) SoftDeletes

func (r *Blueprint) SoftDeletes(column ...string) schema.ColumnDefinition

SoftDeletes creates a new nullable timestamp column for soft deletes. If no column name is specified, it defaults to "soft_deleted_at". Soft deletes mark records as deleted without actually removing them from the database.

func (*Blueprint) SoftDeletesMaxDate added in v0.15.0

func (r *Blueprint) SoftDeletesMaxDate(column ...string) schema.ColumnDefinition

SoftDeletesMaxDate creates a soft delete column using the max-date sentinel strategy. The column is NOT NULL and defaults to "9999-12-31 23:59:59" to indicate active records. This is useful when you need NOT NULL constraints or better index performance.

func (*Blueprint) SoftDeletesMaxDateTz added in v0.15.0

func (r *Blueprint) SoftDeletesMaxDateTz(column ...string) schema.ColumnDefinition

SoftDeletesMaxDateTz creates a soft delete column with timezone using the max-date sentinel strategy. The column is NOT NULL and defaults to "9999-12-31 23:59:59" to indicate active records. This is useful when you need NOT NULL constraints or better index performance.

func (*Blueprint) SoftDeletesTz

func (r *Blueprint) SoftDeletesTz(column ...string) schema.ColumnDefinition

SoftDeletesTz creates a new nullable timestamp with timezone column for soft deletes. If no column name is specified, it defaults to "soft_deleted_at". This is similar to SoftDeletes but includes timezone information.

func (*Blueprint) String

func (r *Blueprint) String(column string, length ...int) schema.ColumnDefinition

String creates a new variable-length string column on the table. The length parameter is optional; if not provided, it defaults to the DefaultStringLength constant. String columns are flexible and use storage proportional to actual content length.

func (*Blueprint) Text

func (r *Blueprint) Text(column string) schema.ColumnDefinition

Text creates a new text column on the table. Text columns can store variable-length strings with no specified maximum length.

func (*Blueprint) Time

func (r *Blueprint) Time(column string, precision ...int) schema.ColumnDefinition

Time creates a new time column on the table. The precision parameter is optional and specifies fractional seconds precision (0-6). Time columns store time of day without date components.

func (*Blueprint) TimeTz

func (r *Blueprint) TimeTz(column string, precision ...int) schema.ColumnDefinition

TimeTz creates a new time with timezone column on the table. The precision parameter is optional and specifies fractional seconds precision (0-6). TimeTz columns store time of day with timezone information.

func (*Blueprint) Timestamp

func (r *Blueprint) Timestamp(column string, precision ...int) schema.ColumnDefinition

Timestamp creates a new timestamp column on the table. The precision parameter is optional and specifies fractional seconds precision (0-6). Timestamp columns store date and time information.

func (*Blueprint) TimestampTz

func (r *Blueprint) TimestampTz(column string, precision ...int) schema.ColumnDefinition

TimestampTz creates a new timestamp with timezone column on the table. The precision parameter is optional and specifies fractional seconds precision (0-6). TimestampTz columns store date, time, and timezone information.

func (*Blueprint) Timestamps

func (r *Blueprint) Timestamps(precision ...int)

Timestamps adds created_at and updated_at timestamp columns to the table. Both columns are nullable and use the same precision if specified. This is a convenience method for adding automatic timestamp tracking.

func (*Blueprint) TimestampsTz

func (r *Blueprint) TimestampsTz(precision ...int)

TimestampsTz adds created_at and updated_at timestamp with timezone columns to the table. Both columns are nullable and use the same precision if specified. This is similar to Timestamps but includes timezone information.

func (*Blueprint) TinyIncrements

func (r *Blueprint) TinyIncrements(column string) schema.ColumnDefinition

TinyIncrements creates a new auto-incrementing tiny integer column on the table. The column will be unsigned and set to auto-increment.

func (*Blueprint) TinyInteger

func (r *Blueprint) TinyInteger(column string) schema.ColumnDefinition

TinyInteger creates a new tiny integer column on the table. Tiny integers can store values from -128 to 127.

func (*Blueprint) TinyText

func (r *Blueprint) TinyText(column string) schema.ColumnDefinition

TinyText creates a new tiny text column on the table. Tiny text columns can store small amounts of text data (up to 255 bytes in some databases).

func (*Blueprint) ToSql

func (r *Blueprint) ToSql(grammar schema.Grammar) ([]string, error)

ToSql converts the blueprint into a slice of SQL statements using the provided grammar. It processes all commands and generates the appropriate database-specific SQL. Returns an error if any command fails to compile.

func (*Blueprint) Unique

func (r *Blueprint) Unique(column ...string) schema.IndexDefinition

Unique creates a new unique index on the table. The column parameter specifies the column(s) to include in the unique index. Returns an IndexDefinition that can be used to configure the index further.

func (*Blueprint) UnsignedBigInteger

func (r *Blueprint) UnsignedBigInteger(column string) schema.ColumnDefinition

UnsignedBigInteger creates a new unsigned big integer column on the table. Unsigned big integers can store values from 0 to 18,446,744,073,709,551,615.

func (*Blueprint) UnsignedInteger

func (r *Blueprint) UnsignedInteger(column string) schema.ColumnDefinition

UnsignedInteger creates a new unsigned integer column on the table. Unsigned integers can store values from 0 to 4,294,967,295.

func (*Blueprint) UnsignedMediumInteger

func (r *Blueprint) UnsignedMediumInteger(column string) schema.ColumnDefinition

UnsignedMediumInteger creates a new unsigned medium integer column on the table. Unsigned medium integers can store values from 0 to 16,777,215.

func (*Blueprint) UnsignedSmallInteger

func (r *Blueprint) UnsignedSmallInteger(column string) schema.ColumnDefinition

UnsignedSmallInteger creates a new unsigned small integer column on the table. Unsigned small integers can store values from 0 to 65,535.

func (*Blueprint) UnsignedTinyInteger

func (r *Blueprint) UnsignedTinyInteger(column string) schema.ColumnDefinition

UnsignedTinyInteger creates a new unsigned tiny integer column on the table. Unsigned tiny integers can store values from 0 to 255.

type ColumnDefinition

type ColumnDefinition struct {
	// contains filtered or unexported fields
}

func (*ColumnDefinition) After

func (*ColumnDefinition) AutoIncrement

func (r *ColumnDefinition) AutoIncrement() schema.ColumnDefinition

func (*ColumnDefinition) Change

func (*ColumnDefinition) Collation

func (r *ColumnDefinition) Collation(collation string) schema.ColumnDefinition

func (*ColumnDefinition) Comment

func (r *ColumnDefinition) Comment(comment string) schema.ColumnDefinition

func (*ColumnDefinition) Default

func (r *ColumnDefinition) Default(def any) schema.ColumnDefinition

func (*ColumnDefinition) First

func (*ColumnDefinition) GetAfter

func (r *ColumnDefinition) GetAfter() string

func (*ColumnDefinition) GetAllowed

func (r *ColumnDefinition) GetAllowed() []any

func (*ColumnDefinition) GetAutoIncrement

func (r *ColumnDefinition) GetAutoIncrement() bool

func (*ColumnDefinition) GetChange

func (r *ColumnDefinition) GetChange() bool

func (*ColumnDefinition) GetCollation

func (r *ColumnDefinition) GetCollation() string

func (*ColumnDefinition) GetComment

func (r *ColumnDefinition) GetComment() string

func (*ColumnDefinition) GetDefault

func (r *ColumnDefinition) GetDefault() any

func (*ColumnDefinition) GetFirst

func (r *ColumnDefinition) GetFirst() bool

func (*ColumnDefinition) GetLength

func (r *ColumnDefinition) GetLength() int

func (*ColumnDefinition) GetName

func (r *ColumnDefinition) GetName() string

func (*ColumnDefinition) GetNullable

func (r *ColumnDefinition) GetNullable() bool

func (*ColumnDefinition) GetOnUpdate

func (r *ColumnDefinition) GetOnUpdate() any

func (*ColumnDefinition) GetPlaces

func (r *ColumnDefinition) GetPlaces() int

func (*ColumnDefinition) GetPrecision

func (r *ColumnDefinition) GetPrecision() int

func (*ColumnDefinition) GetSrid added in v0.7.0

func (r *ColumnDefinition) GetSrid() int

func (*ColumnDefinition) GetTotal

func (r *ColumnDefinition) GetTotal() int

func (*ColumnDefinition) GetType

func (r *ColumnDefinition) GetType() string

func (*ColumnDefinition) GetUnsigned

func (r *ColumnDefinition) GetUnsigned() bool

func (*ColumnDefinition) GetUseCurrent

func (r *ColumnDefinition) GetUseCurrent() bool

func (*ColumnDefinition) GetUseCurrentOnUpdate

func (r *ColumnDefinition) GetUseCurrentOnUpdate() bool

func (*ColumnDefinition) IsSetComment

func (r *ColumnDefinition) IsSetComment() bool

func (*ColumnDefinition) Nullable

func (*ColumnDefinition) OnUpdate

func (r *ColumnDefinition) OnUpdate(value any) schema.ColumnDefinition

func (*ColumnDefinition) Places

func (r *ColumnDefinition) Places(places int) schema.ColumnDefinition

func (*ColumnDefinition) Srid added in v0.7.0

func (*ColumnDefinition) Total

func (r *ColumnDefinition) Total(total int) schema.ColumnDefinition

func (*ColumnDefinition) Unsigned

func (*ColumnDefinition) UseCurrent

func (r *ColumnDefinition) UseCurrent() schema.ColumnDefinition

func (*ColumnDefinition) UseCurrentOnUpdate

func (r *ColumnDefinition) UseCurrentOnUpdate() schema.ColumnDefinition

type CommonSchema

type CommonSchema struct {
	// contains filtered or unexported fields
}

func NewCommonSchema

func NewCommonSchema(grammar schema.Grammar, orm orm.Orm) *CommonSchema

func (*CommonSchema) GetTables

func (r *CommonSchema) GetTables() ([]schema.Table, error)

func (*CommonSchema) GetViews

func (r *CommonSchema) GetViews() ([]schema.View, error)

func (*CommonSchema) WithTransaction added in v0.16.0

func (r *CommonSchema) WithTransaction(tx orm.Query) *CommonSchema

type ForeignKeyDefinition

type ForeignKeyDefinition struct {
	// contains filtered or unexported fields
}

func (*ForeignKeyDefinition) CascadeOnDelete

func (r *ForeignKeyDefinition) CascadeOnDelete() schema.ForeignKeyDefinition

func (*ForeignKeyDefinition) CascadeOnUpdate

func (r *ForeignKeyDefinition) CascadeOnUpdate() schema.ForeignKeyDefinition

func (*ForeignKeyDefinition) Name

func (*ForeignKeyDefinition) NoActionOnDelete

func (r *ForeignKeyDefinition) NoActionOnDelete() schema.ForeignKeyDefinition

func (*ForeignKeyDefinition) NoActionOnUpdate

func (r *ForeignKeyDefinition) NoActionOnUpdate() schema.ForeignKeyDefinition

func (*ForeignKeyDefinition) NullOnDelete

func (*ForeignKeyDefinition) On

func (*ForeignKeyDefinition) References

func (r *ForeignKeyDefinition) References(columns ...string) schema.ForeignKeyDefinition

func (*ForeignKeyDefinition) RestrictOnDelete

func (r *ForeignKeyDefinition) RestrictOnDelete() schema.ForeignKeyDefinition

func (*ForeignKeyDefinition) RestrictOnUpdate

func (r *ForeignKeyDefinition) RestrictOnUpdate() schema.ForeignKeyDefinition

type IndexDefinition

type IndexDefinition struct {
	// contains filtered or unexported fields
}

func (*IndexDefinition) Algorithm

func (r *IndexDefinition) Algorithm(algorithm string) schema.IndexDefinition

func (*IndexDefinition) Deferrable

func (r *IndexDefinition) Deferrable() schema.IndexDefinition

func (*IndexDefinition) InitiallyImmediate

func (r *IndexDefinition) InitiallyImmediate() schema.IndexDefinition

func (*IndexDefinition) Language

func (r *IndexDefinition) Language(name string) schema.IndexDefinition

func (*IndexDefinition) Name

type MigrationSignatureFormat added in v0.16.0

type MigrationSignatureFormat string

MigrationSignatureFormat defines the format for migration signatures

const (
	// MigrationSignatureFormatDateTime uses timestamp-based format (default)
	MigrationSignatureFormatDateTime MigrationSignatureFormat = "datetime" // 2026_06_14_1200_description
	// MigrationSignatureFormatDate uses sequence-based format
	MigrationSignatureFormatDate MigrationSignatureFormat = "date" // 2026_06_14_001_description
	// MigrationSignatureFormatCustom uses no prefix format restriction
	MigrationSignatureFormatCustom MigrationSignatureFormat = "custom" // any format
)

type MysqlSchema

type MysqlSchema struct {
	contractsschema.CommonSchema
	// contains filtered or unexported fields
}

func NewMysqlSchema

func NewMysqlSchema(grammar *grammars.Mysql, orm orm.Orm, prefix string) *MysqlSchema

func (*MysqlSchema) DropAllTables

func (r *MysqlSchema) DropAllTables() error

func (*MysqlSchema) DropAllTypes

func (r *MysqlSchema) DropAllTypes() error

func (*MysqlSchema) DropAllViews

func (r *MysqlSchema) DropAllViews() error

func (*MysqlSchema) GetColumns

func (r *MysqlSchema) GetColumns(table string) ([]contractsschema.Column, error)

func (*MysqlSchema) GetIndexes

func (r *MysqlSchema) GetIndexes(table string) ([]contractsschema.Index, error)

func (*MysqlSchema) GetTypes

func (r *MysqlSchema) GetTypes() ([]contractsschema.Type, error)

func (*MysqlSchema) WithTransaction added in v0.16.0

func (r *MysqlSchema) WithTransaction(tx orm.Query) *MysqlSchema

type OracleSchema added in v0.7.0

type OracleSchema struct {
	contractsschema.CommonSchema
	// contains filtered or unexported fields
}

func NewOracleSchema added in v0.7.0

func NewOracleSchema(grammar *grammars.Oracle, orm orm.Orm, prefix string) *OracleSchema

func (*OracleSchema) DropAllTables added in v0.7.0

func (r *OracleSchema) DropAllTables() error

func (*OracleSchema) DropAllTypes added in v0.7.0

func (r *OracleSchema) DropAllTypes() error

func (*OracleSchema) DropAllViews added in v0.7.0

func (r *OracleSchema) DropAllViews() error

func (*OracleSchema) GetColumns added in v0.7.0

func (r *OracleSchema) GetColumns(table string) ([]contractsschema.Column, error)

func (*OracleSchema) GetIndexes added in v0.7.0

func (r *OracleSchema) GetIndexes(table string) ([]contractsschema.Index, error)

func (*OracleSchema) GetTypes added in v0.7.0

func (r *OracleSchema) GetTypes() ([]contractsschema.Type, error)

func (*OracleSchema) WithTransaction added in v0.16.0

func (r *OracleSchema) WithTransaction(tx orm.Query) *OracleSchema

type PostgresSchema

type PostgresSchema struct {
	contractsschema.CommonSchema
	// contains filtered or unexported fields
}

func NewPostgresSchema

func NewPostgresSchema(grammar *grammars.Postgres, orm orm.Orm, schema, prefix string) *PostgresSchema

func (*PostgresSchema) DropAllTables

func (r *PostgresSchema) DropAllTables() error

func (*PostgresSchema) DropAllTypes

func (r *PostgresSchema) DropAllTypes() error

func (*PostgresSchema) DropAllViews

func (r *PostgresSchema) DropAllViews() error

func (*PostgresSchema) GetColumns

func (r *PostgresSchema) GetColumns(table string) ([]contractsschema.Column, error)

func (*PostgresSchema) GetIndexes

func (r *PostgresSchema) GetIndexes(table string) ([]contractsschema.Index, error)

func (*PostgresSchema) GetTypes

func (r *PostgresSchema) GetTypes() ([]contractsschema.Type, error)

func (*PostgresSchema) WithTransaction added in v0.16.0

func (r *PostgresSchema) WithTransaction(tx orm.Query) *PostgresSchema

type Schema

type Schema struct {
	contractsschema.CommonSchema
	contractsschema.DriverSchema
	// contains filtered or unexported fields
}

func NewSchema

func NewSchema(config config.Config, log log.Log, orm contractsorm.Orm) (*Schema, error)

func (*Schema) Connection

func (r *Schema) Connection(name string) contractsschema.Schema

func (*Schema) Create

func (r *Schema) Create(table string, callback func(table contractsschema.Blueprint)) error

func (*Schema) Drop

func (r *Schema) Drop(table string) error

func (*Schema) DropColumns

func (r *Schema) DropColumns(table string, columns []string) error

func (*Schema) DropIfExists

func (r *Schema) DropIfExists(table string) error

func (*Schema) GetColumnListing

func (r *Schema) GetColumnListing(table string) []string

func (*Schema) GetConnection

func (r *Schema) GetConnection() string

func (*Schema) GetForeignKeys

func (r *Schema) GetForeignKeys(table string) ([]contractsschema.ForeignKey, error)

func (*Schema) GetIndexListing

func (r *Schema) GetIndexListing(table string) []string

func (*Schema) GetIndexes

func (r *Schema) GetIndexes(table string) ([]contractsschema.Index, error)

func (*Schema) GetTableListing

func (r *Schema) GetTableListing() []string

func (*Schema) GetTables added in v0.5.0

func (r *Schema) GetTables() ([]contractsschema.Table, error)

func (*Schema) HasColumn

func (r *Schema) HasColumn(table, column string) bool

func (*Schema) HasColumns

func (r *Schema) HasColumns(table string, columns []string) bool

func (*Schema) HasIndex

func (r *Schema) HasIndex(table, index string) bool

func (*Schema) HasTable

func (r *Schema) HasTable(name string) bool

func (*Schema) HasType

func (r *Schema) HasType(name string) bool

func (*Schema) HasView

func (r *Schema) HasView(name string) bool

func (*Schema) Orm

func (r *Schema) Orm() contractsorm.Orm

func (*Schema) Rename

func (r *Schema) Rename(from, to string) error

func (*Schema) RenameColumn

func (r *Schema) RenameColumn(table, from, to string) error

func (*Schema) SetConnection

func (r *Schema) SetConnection(name string)

func (*Schema) Sql

func (r *Schema) Sql(sql string) error

func (*Schema) Table

func (r *Schema) Table(table string, callback func(table contractsschema.Blueprint)) error

func (*Schema) WithTransaction added in v0.16.0

func (r *Schema) WithTransaction(tx contractsorm.Query) contractsschema.Schema

type SqliteSchema

type SqliteSchema struct {
	schema.CommonSchema
	// contains filtered or unexported fields
}

func NewSqliteSchema

func NewSqliteSchema(grammar *grammars.Sqlite, orm orm.Orm, prefix string) *SqliteSchema

func (*SqliteSchema) DropAllTables

func (r *SqliteSchema) DropAllTables() error

func (*SqliteSchema) DropAllTypes

func (r *SqliteSchema) DropAllTypes() error

func (*SqliteSchema) DropAllViews

func (r *SqliteSchema) DropAllViews() error

func (*SqliteSchema) GetColumns

func (r *SqliteSchema) GetColumns(table string) ([]schema.Column, error)

func (*SqliteSchema) GetIndexes

func (r *SqliteSchema) GetIndexes(table string) ([]schema.Index, error)

func (*SqliteSchema) GetTypes

func (r *SqliteSchema) GetTypes() ([]schema.Type, error)

func (*SqliteSchema) WithTransaction added in v0.16.0

func (r *SqliteSchema) WithTransaction(tx orm.Query) *SqliteSchema

type SqlserverSchema

type SqlserverSchema struct {
	contractsschema.CommonSchema
	// contains filtered or unexported fields
}

func NewSqlserverSchema

func NewSqlserverSchema(grammar *grammars.Sqlserver, orm orm.Orm, prefix string) *SqlserverSchema

func (*SqlserverSchema) DropAllTables

func (r *SqlserverSchema) DropAllTables() error

func (*SqlserverSchema) DropAllTypes

func (r *SqlserverSchema) DropAllTypes() error

func (*SqlserverSchema) DropAllViews

func (r *SqlserverSchema) DropAllViews() error

func (*SqlserverSchema) GetColumns

func (r *SqlserverSchema) GetColumns(table string) ([]contractsschema.Column, error)

func (*SqlserverSchema) GetIndexes

func (r *SqlserverSchema) GetIndexes(table string) ([]contractsschema.Index, error)

func (*SqlserverSchema) GetTypes

func (r *SqlserverSchema) GetTypes() ([]contractsschema.Type, error)

func (*SqlserverSchema) WithTransaction added in v0.16.0

func (r *SqlserverSchema) WithTransaction(tx orm.Query) *SqlserverSchema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL