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 ( // AttachmentsColumns holds the columns for the "attachments" table. AttachmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "file_path", Type: field.TypeString, Nullable: true}, {Name: "file_type", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "patient_attachment", Type: field.TypeInt, Nullable: true}, {Name: "visit_attachment", Type: field.TypeInt, Nullable: true}, } // AttachmentsTable holds the schema information for the "attachments" table. AttachmentsTable = &schema.Table{ Name: "attachments", Columns: AttachmentsColumns, PrimaryKey: []*schema.Column{AttachmentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "attachments_patients_attachment", Columns: []*schema.Column{AttachmentsColumns[6]}, RefColumns: []*schema.Column{PatientsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "attachments_visits_attachment", Columns: []*schema.Column{AttachmentsColumns[7]}, RefColumns: []*schema.Column{VisitsColumns[0]}, OnDelete: schema.SetNull, }, }, } // PatientsColumns holds the columns for the "patients" table. PatientsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "first_name", Type: field.TypeString, Nullable: true}, {Name: "last_name", Type: field.TypeString, Nullable: true}, {Name: "father_name", Type: field.TypeString, Nullable: true}, {Name: "phone", Type: field.TypeString, Nullable: true}, {Name: "national_code", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "identity_code", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, } // PatientsTable holds the schema information for the "patients" table. PatientsTable = &schema.Table{ Name: "patients", Columns: PatientsColumns, PrimaryKey: []*schema.Column{PatientsColumns[0]}, } // ReceptionsColumns holds the columns for the "receptions" table. ReceptionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "reception_for", Type: field.TypeTime}, {Name: "visit_duration", Type: field.TypeInt}, {Name: "insurance_code", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "patient_reception", Type: field.TypeInt, Nullable: true}, } // ReceptionsTable holds the schema information for the "receptions" table. ReceptionsTable = &schema.Table{ Name: "receptions", Columns: ReceptionsColumns, PrimaryKey: []*schema.Column{ReceptionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "receptions_patients_reception", Columns: []*schema.Column{ReceptionsColumns[8]}, RefColumns: []*schema.Column{PatientsColumns[0]}, OnDelete: schema.SetNull, }, }, } // VisitsColumns holds the columns for the "visits" table. VisitsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "visit_price", Type: field.TypeString, Nullable: true}, {Name: "visited_at", Type: field.TypeTime, Nullable: true}, {Name: "payment_type", Type: field.TypeString, Nullable: true}, {Name: "is_paid", Type: field.TypeBool, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "reception_visit", Type: field.TypeInt, Nullable: true}, } // VisitsTable holds the schema information for the "visits" table. VisitsTable = &schema.Table{ Name: "visits", Columns: VisitsColumns, PrimaryKey: []*schema.Column{VisitsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "visits_receptions_visit", Columns: []*schema.Column{VisitsColumns[8]}, RefColumns: []*schema.Column{ReceptionsColumns[0]}, OnDelete: schema.SetNull, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AttachmentsTable, PatientsTable, ReceptionsTable, VisitsTable, } )
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.