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 ( // AlertsColumns holds the columns for the "alerts" table. AlertsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID, Unique: true}, {Name: "incident_id", Type: field.TypeUUID, Nullable: true}, {Name: "name", Type: field.TypeString}, {Name: "time", Type: field.TypeTime}, {Name: "level", Type: field.TypeInt}, {Name: "username", Type: field.TypeString}, {Name: "region", Type: field.TypeString}, {Name: "probe_os", Type: field.TypeString}, {Name: "probe_host", Type: field.TypeString}, {Name: "error", Type: field.TypeString, Nullable: true}, } // AlertsTable holds the schema information for the "alerts" table. AlertsTable = &schema.Table{ Name: "alerts", Columns: AlertsColumns, PrimaryKey: []*schema.Column{AlertsColumns[0]}, Indexes: []*schema.Index{ { Name: "alert_uuid", Unique: true, Columns: []*schema.Column{AlertsColumns[1]}, }, { Name: "alert_incident_id", Unique: false, Columns: []*schema.Column{AlertsColumns[2]}, }, { Name: "alert_name", Unique: false, Columns: []*schema.Column{AlertsColumns[3]}, }, }, } // CountersColumns holds the columns for the "counters" table. CountersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "value", Type: field.TypeFloat64}, {Name: "alert_counters", Type: field.TypeInt, Nullable: true}, {Name: "incident_counters", Type: field.TypeInt, Nullable: true}, } // CountersTable holds the schema information for the "counters" table. CountersTable = &schema.Table{ Name: "counters", Columns: CountersColumns, PrimaryKey: []*schema.Column{CountersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "counters_alerts_Counters", Columns: []*schema.Column{CountersColumns[3]}, RefColumns: []*schema.Column{AlertsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "counters_incidents_Counters", Columns: []*schema.Column{CountersColumns[4]}, RefColumns: []*schema.Column{IncidentsColumns[0]}, OnDelete: schema.Cascade, }, }, } // FailuresColumns holds the columns for the "failures" table. FailuresColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "error", Type: field.TypeString}, {Name: "idx", Type: field.TypeInt}, {Name: "alert_failures", Type: field.TypeInt, Nullable: true}, {Name: "incident_failures", Type: field.TypeInt, Nullable: true}, } // FailuresTable holds the schema information for the "failures" table. FailuresTable = &schema.Table{ Name: "failures", Columns: FailuresColumns, PrimaryKey: []*schema.Column{FailuresColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "failures_alerts_Failures", Columns: []*schema.Column{FailuresColumns[3]}, RefColumns: []*schema.Column{AlertsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "failures_incidents_Failures", Columns: []*schema.Column{FailuresColumns[4]}, RefColumns: []*schema.Column{IncidentsColumns[0]}, OnDelete: schema.Cascade, }, }, } // FilesColumns holds the columns for the "files" table. FilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID}, {Name: "name", Type: field.TypeString}, {Name: "type", Type: field.TypeString}, {Name: "ext", Type: field.TypeString}, {Name: "size", Type: field.TypeInt}, {Name: "payload", Type: field.TypeBytes}, {Name: "alert_files", Type: field.TypeInt, Nullable: true}, {Name: "incident_files", Type: field.TypeInt, Nullable: true}, } // FilesTable holds the schema information for the "files" table. FilesTable = &schema.Table{ Name: "files", Columns: FilesColumns, PrimaryKey: []*schema.Column{FilesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "files_alerts_Files", Columns: []*schema.Column{FilesColumns[7]}, RefColumns: []*schema.Column{AlertsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "files_incidents_Files", Columns: []*schema.Column{FilesColumns[8]}, RefColumns: []*schema.Column{IncidentsColumns[0]}, OnDelete: schema.Cascade, }, }, } // IncidentsColumns holds the columns for the "incidents" table. IncidentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "uuid", Type: field.TypeUUID, Unique: true}, {Name: "incident_id", Type: field.TypeUUID, Nullable: true}, {Name: "name", Type: field.TypeString}, {Name: "time", Type: field.TypeTime}, {Name: "level", Type: field.TypeInt}, {Name: "username", Type: field.TypeString}, {Name: "region", Type: field.TypeString}, {Name: "probe_os", Type: field.TypeString}, {Name: "probe_host", Type: field.TypeString}, {Name: "error", Type: field.TypeString, Nullable: true}, {Name: "start", Type: field.TypeTime}, {Name: "end", Type: field.TypeTime, Nullable: true}, {Name: "state", Type: field.TypeBytes}, } // IncidentsTable holds the schema information for the "incidents" table. IncidentsTable = &schema.Table{ Name: "incidents", Columns: IncidentsColumns, PrimaryKey: []*schema.Column{IncidentsColumns[0]}, Indexes: []*schema.Index{ { Name: "incident_uuid", Unique: true, Columns: []*schema.Column{IncidentsColumns[1]}, }, { Name: "incident_incident_id", Unique: false, Columns: []*schema.Column{IncidentsColumns[2]}, }, { Name: "incident_name", Unique: false, Columns: []*schema.Column{IncidentsColumns[3]}, }, { Name: "incident_start", Unique: false, Columns: []*schema.Column{IncidentsColumns[11]}, }, { Name: "incident_end", Unique: false, Columns: []*schema.Column{IncidentsColumns[12]}, }, }, } // StatusColumns holds the columns for the "status" table. StatusColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "value", Type: field.TypeString}, {Name: "alert_stati", Type: field.TypeInt, Nullable: true}, {Name: "incident_stati", Type: field.TypeInt, Nullable: true}, } // StatusTable holds the schema information for the "status" table. StatusTable = &schema.Table{ Name: "status", Columns: StatusColumns, PrimaryKey: []*schema.Column{StatusColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "status_alerts_Stati", Columns: []*schema.Column{StatusColumns[3]}, RefColumns: []*schema.Column{AlertsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "status_incidents_Stati", Columns: []*schema.Column{StatusColumns[4]}, RefColumns: []*schema.Column{IncidentsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AlertsTable, CountersTable, FailuresTable, FilesTable, IncidentsTable, StatusTable, } )
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.