Documentation ¶
Index ¶
- Variables
- func Create(ctx context.Context, s *Schema, tables []*schema.Table, ...) error
- func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error
- func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error
- type Schema
- func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error
- func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // WithGlobalUniqueID sets the universal ids options to the migration. // If this option is enabled, ent migration will allocate a 1<<32 range // for the ids of each entity (table). // Note that this option cannot be applied on tables that already exist. WithGlobalUniqueID = schema.WithGlobalUniqueID // WithDropColumn sets the drop column option to the migration. // If this option is enabled, ent migration will drop old columns // that were used for both fields and edges. This defaults to false. WithDropColumn = schema.WithDropColumn // WithDropIndex sets the drop index option to the migration. // If this option is enabled, ent migration will drop old indexes // that were defined in the schema. This defaults to false. // Note that unique constraints are defined using `UNIQUE INDEX`, // and therefore, it's recommended to enable this option to get more // flexibility in the schema changes. WithDropIndex = schema.WithDropIndex // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. WithForeignKeys = schema.WithForeignKeys )
View Source
var ( // BlocksColumns holds the columns for the "blocks" table. BlocksColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID}, {Name: "source_chain_id", Type: field.TypeUint64}, {Name: "block_height", Type: field.TypeUint64}, {Name: "block_hash", Type: field.TypeBytes, Size: 32}, {Name: "timestamp", Type: field.TypeTime}, {Name: "created_at", Type: field.TypeTime}, } // BlocksTable holds the schema information for the "blocks" table. BlocksTable = &schema.Table{ Name: "blocks", Columns: BlocksColumns, PrimaryKey: []*schema.Column{BlocksColumns[0]}, } // ChainsColumns holds the columns for the "chains" table. ChainsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "chain_id", Type: field.TypeUint64}, {Name: "name", Type: field.TypeString}, } // ChainsTable holds the schema information for the "chains" table. ChainsTable = &schema.Table{ Name: "chains", Columns: ChainsColumns, PrimaryKey: []*schema.Column{ChainsColumns[0]}, } // MsgsColumns holds the columns for the "msgs" table. MsgsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID}, {Name: "source_msg_sender", Type: field.TypeBytes, Size: 20}, {Name: "dest_address", Type: field.TypeBytes, Size: 20}, {Name: "data", Type: field.TypeBytes}, {Name: "dest_gas_limit", Type: field.TypeUint64}, {Name: "source_chain_id", Type: field.TypeUint64}, {Name: "dest_chain_id", Type: field.TypeUint64}, {Name: "stream_offset", Type: field.TypeUint64}, {Name: "tx_hash", Type: field.TypeBytes, Size: 32}, {Name: "created_at", Type: field.TypeTime}, {Name: "block_msgs", Type: field.TypeInt, Nullable: true}, } // MsgsTable holds the schema information for the "msgs" table. MsgsTable = &schema.Table{ Name: "msgs", Columns: MsgsColumns, PrimaryKey: []*schema.Column{MsgsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "msgs_blocks_Msgs", Columns: []*schema.Column{MsgsColumns[11]}, RefColumns: []*schema.Column{BlocksColumns[0]}, OnDelete: schema.SetNull, }, }, } // ReceiptsColumns holds the columns for the "receipts" table. ReceiptsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID}, {Name: "gas_used", Type: field.TypeUint64}, {Name: "success", Type: field.TypeBool}, {Name: "relayer_address", Type: field.TypeBytes, Size: 20}, {Name: "source_chain_id", Type: field.TypeUint64}, {Name: "dest_chain_id", Type: field.TypeUint64}, {Name: "stream_offset", Type: field.TypeUint64}, {Name: "tx_hash", Type: field.TypeBytes, Size: 32}, {Name: "created_at", Type: field.TypeTime}, {Name: "block_receipts", Type: field.TypeInt, Nullable: true}, } // ReceiptsTable holds the schema information for the "receipts" table. ReceiptsTable = &schema.Table{ Name: "receipts", Columns: ReceiptsColumns, PrimaryKey: []*schema.Column{ReceiptsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "receipts_blocks_Receipts", Columns: []*schema.Column{ReceiptsColumns[10]}, RefColumns: []*schema.Column{BlocksColumns[0]}, OnDelete: schema.SetNull, }, }, } // XproviderCursorsColumns holds the columns for the "xprovider_cursors" table. XproviderCursorsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID}, {Name: "chain_id", Type: field.TypeUint64}, {Name: "height", Type: field.TypeUint64}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, } // XproviderCursorsTable holds the schema information for the "xprovider_cursors" table. XproviderCursorsTable = &schema.Table{ Name: "xprovider_cursors", Columns: XproviderCursorsColumns, PrimaryKey: []*schema.Column{XproviderCursorsColumns[0]}, Indexes: []*schema.Index{ { Name: "xprovidercursor_chain_id", Unique: true, Columns: []*schema.Column{XproviderCursorsColumns[2]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BlocksTable, ChainsTable, MsgsTable, ReceiptsTable, XproviderCursorsTable, } )
Functions ¶
func Create ¶
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error
Create creates all table resources using the given schema driver.
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
func (*Schema) Diff ¶
Diff creates a migration file containing the statements to resolve the diff between the Ent schema and the connected database.
func (*Schema) NamedDiff ¶
NamedDiff creates a named migration file containing the statements to resolve the diff between the Ent schema and the connected database.
Click to show internal directories.
Click to hide internal directories.