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}, {Name: "update_type", Type: field.TypeString, Default: "incremental"}, } // 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: "update_type", Type: field.TypeEnum, Enums: []string{"full", "incremental"}}, {Name: "os", Type: field.TypeString, Default: ""}, {Name: "arch", Type: field.TypeString, Default: ""}, {Name: "package_path", Type: field.TypeString, Nullable: true}, {Name: "package_hash_sha256", Type: field.TypeString, Nullable: true}, {Name: "resource_path", Type: field.TypeString, Nullable: true}, {Name: "file_hashes", Type: field.TypeJSON, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "storage_old_version", Type: field.TypeInt, Nullable: true}, {Name: "version_storages", Type: field.TypeInt}, } // 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_old_version", Columns: []*schema.Column{StoragesColumns[9]}, RefColumns: []*schema.Column{VersionsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "storages_versions_storages", Columns: []*schema.Column{StoragesColumns[10]}, RefColumns: []*schema.Column{VersionsColumns[0]}, OnDelete: schema.NoAction, }, }, } // VersionsColumns holds the columns for the "versions" table. VersionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "channel", Type: field.TypeEnum, Enums: []string{"stable", "beta", "alpha"}, Default: "stable"}, {Name: "name", Type: field.TypeString}, {Name: "number", Type: field.TypeUint64}, {Name: "release_note", Type: field.TypeString, Default: "", SchemaType: map[string]string{"mysql": "longtext"}}, {Name: "custom_data", Type: field.TypeString, Default: "", SchemaType: map[string]string{"mysql": "longtext"}}, {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[7]}, 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.