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 ( // DataKeysColumns holds the columns for the "data_keys" table. DataKeysColumns = []*schema.Column{ {Name: "id", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "bytea", "sqlite3": "blob"}}, {Name: "purpose", Type: field.TypeString}, {Name: "subject", Type: field.TypeString, Default: ""}, {Name: "epoch", Type: field.TypeUint32}, {Name: "algorithm", Type: field.TypeUint8}, {Name: "kek_version", Type: field.TypeUint32}, {Name: "wrapped", Type: field.TypeBytes, Nullable: true}, {Name: "state", Type: field.TypeUint8}, {Name: "reserved", Type: field.TypeUint64, Default: 0}, {Name: "created_at", Type: field.TypeTime}, {Name: "wrapped_under", Type: field.TypeJSON}, {Name: "is_current", Type: field.TypeBool, Default: false}, {Name: "kek_id", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "bytea", "sqlite3": "blob"}}, } // DataKeysTable holds the schema information for the "data_keys" table. DataKeysTable = &schema.Table{ Name: "data_keys", Columns: DataKeysColumns, PrimaryKey: []*schema.Column{DataKeysColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "data_keys_ke_ks_kek", Columns: []*schema.Column{DataKeysColumns[12]}, RefColumns: []*schema.Column{KeKsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "datakey_purpose_subject_epoch", Unique: true, Columns: []*schema.Column{DataKeysColumns[1], DataKeysColumns[2], DataKeysColumns[3]}, }, { Name: "datakey_purpose_subject", Unique: true, Columns: []*schema.Column{DataKeysColumns[1], DataKeysColumns[2]}, Annotation: &entsql.IndexAnnotation{ Where: "is_current", }, }, { Name: "datakey_kek_id_kek_version", Unique: false, Columns: []*schema.Column{DataKeysColumns[12], DataKeysColumns[5]}, }, { Name: "datakey_purpose_state", Unique: false, Columns: []*schema.Column{DataKeysColumns[1], DataKeysColumns[7]}, }, }, } // KeKsColumns holds the columns for the "ke_ks" table. KeKsColumns = []*schema.Column{ {Name: "id", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "bytea", "sqlite3": "blob"}}, {Name: "purpose", Type: field.TypeString}, {Name: "provider", Type: field.TypeString}, {Name: "provider_ref", Type: field.TypeString}, {Name: "state", Type: field.TypeUint8}, {Name: "created_at", Type: field.TypeTime}, } // KeKsTable holds the schema information for the "ke_ks" table. KeKsTable = &schema.Table{ Name: "ke_ks", Columns: KeKsColumns, PrimaryKey: []*schema.Column{KeKsColumns[0]}, Indexes: []*schema.Index{ { Name: "kek_purpose", Unique: true, Columns: []*schema.Column{KeKsColumns[1]}, Annotation: &entsql.IndexAnnotation{ Where: "state = 1", }, }, }, } // KekVersionsColumns holds the columns for the "kek_versions" table. KekVersionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "version", Type: field.TypeUint32}, {Name: "state", Type: field.TypeUint8}, {Name: "provider_ref", Type: field.TypeString, Default: ""}, {Name: "created_at", Type: field.TypeTime}, {Name: "activated_at", Type: field.TypeTime, Nullable: true}, {Name: "rotated_at", Type: field.TypeTime, Nullable: true}, {Name: "retire_after", Type: field.TypeTime, Nullable: true}, {Name: "kek_id", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "bytea", "sqlite3": "blob"}}, } // KekVersionsTable holds the schema information for the "kek_versions" table. KekVersionsTable = &schema.Table{ Name: "kek_versions", Columns: KekVersionsColumns, PrimaryKey: []*schema.Column{KekVersionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "kek_versions_ke_ks_kek", Columns: []*schema.Column{KekVersionsColumns[8]}, RefColumns: []*schema.Column{KeKsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "kekversion_kek_id_version", Unique: true, Columns: []*schema.Column{KekVersionsColumns[8], KekVersionsColumns[1]}, }, { Name: "kekversion_kek_id", Unique: true, Columns: []*schema.Column{KekVersionsColumns[8]}, Annotation: &entsql.IndexAnnotation{ Where: "state = 2", }, }, }, } // SentinelsColumns holds the columns for the "sentinels" table. SentinelsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "version", Type: field.TypeUint32}, {Name: "envelope", Type: field.TypeString, Size: 2147483647}, {Name: "created_at", Type: field.TypeTime}, {Name: "kek_id", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "bytea", "sqlite3": "blob"}}, } // SentinelsTable holds the schema information for the "sentinels" table. SentinelsTable = &schema.Table{ Name: "sentinels", Columns: SentinelsColumns, PrimaryKey: []*schema.Column{SentinelsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "sentinels_ke_ks_kek", Columns: []*schema.Column{SentinelsColumns[4]}, RefColumns: []*schema.Column{KeKsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "sentinel_kek_id_version", Unique: true, Columns: []*schema.Column{SentinelsColumns[4], SentinelsColumns[1]}, }, }, } // ShredsColumns holds the columns for the "shreds" table. ShredsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "purpose", Type: field.TypeString}, {Name: "subject", Type: field.TypeString}, {Name: "requested_at", Type: field.TypeTime}, {Name: "versions", Type: field.TypeJSON}, {Name: "deks", Type: field.TypeInt, Default: 0}, {Name: "completed_at", Type: field.TypeTime, Nullable: true}, } // ShredsTable holds the schema information for the "shreds" table. ShredsTable = &schema.Table{ Name: "shreds", Columns: ShredsColumns, PrimaryKey: []*schema.Column{ShredsColumns[0]}, Indexes: []*schema.Index{ { Name: "shred_purpose_subject", Unique: true, Columns: []*schema.Column{ShredsColumns[1], ShredsColumns[2]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ DataKeysTable, KeKsTable, KekVersionsTable, SentinelsTable, ShredsTable, } )
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.