Documentation
¶
Index ¶
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 ( // ResourcesColumns holds the columns for the "resources" table. ResourcesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "created_at", Type: field.TypeTime}, } // ResourcesTable holds the schema information for the "resources" table. ResourcesTable = &schema.Table{ Name: "resources", Columns: ResourcesColumns, PrimaryKey: []*schema.Column{ResourcesColumns[0]}, } // StoragesColumns holds the columns for the "storages" table. StoragesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "directory", Type: field.TypeString}, {Name: "created_at", Type: field.TypeTime}, {Name: "version_storage", Type: field.TypeInt, Unique: true, Nullable: true}, } // StoragesTable holds the schema information for the "storages" table. StoragesTable = &schema.Table{ Name: "storages", Columns: StoragesColumns, PrimaryKey: []*schema.Column{StoragesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "storages_versions_storage", Columns: []*schema.Column{StoragesColumns[3]}, RefColumns: []*schema.Column{VersionsColumns[0]}, OnDelete: schema.SetNull, }, }, } // VersionsColumns holds the columns for the "versions" table. VersionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "number", Type: field.TypeUint64}, {Name: "file_hashes", Type: field.TypeJSON, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "resource_versions", Type: field.TypeString, Nullable: true}, } // VersionsTable holds the schema information for the "versions" table. VersionsTable = &schema.Table{ Name: "versions", Columns: VersionsColumns, PrimaryKey: []*schema.Column{VersionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "versions_resources_versions", Columns: []*schema.Column{VersionsColumns[5]}, RefColumns: []*schema.Column{ResourcesColumns[0]}, OnDelete: schema.SetNull, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ ResourcesTable, StoragesTable, VersionsTable, } )
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
Click to show internal directories.
Click to hide internal directories.