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 // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture )
View Source
var ( // AlertsColumns holds the columns for the "alerts" table. AlertsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, } // AlertsTable holds the schema information for the "alerts" table. AlertsTable = &schema.Table{ Name: "alerts", Columns: AlertsColumns, PrimaryKey: []*schema.Column{AlertsColumns[0]}, ForeignKeys: []*schema.ForeignKey{}, } // ClinicalResultsColumns holds the columns for the "clinical_results" table. ClinicalResultsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "general_discomfort", Type: field.TypeBool}, {Name: "fever", Type: field.TypeBool}, {Name: "third_age", Type: field.TypeBool}, {Name: "dyspnea", Type: field.TypeBool}, {Name: "test_clinical", Type: field.TypeUUID, Nullable: true}, } // ClinicalResultsTable holds the schema information for the "clinical_results" table. ClinicalResultsTable = &schema.Table{ Name: "clinical_results", Columns: ClinicalResultsColumns, PrimaryKey: []*schema.Column{ClinicalResultsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "clinical_results_tests_clinical", Columns: []*schema.Column{ClinicalResultsColumns[5]}, RefColumns: []*schema.Column{TestsColumns[0]}, OnDelete: schema.SetNull, }, }, } // DoctorsColumns holds the columns for the "doctors" table. DoctorsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "name", Type: field.TypeJSON}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "phone", Type: field.TypeString, Unique: true}, {Name: "state", Type: field.TypeEnum, Enums: []string{"idle", "working", "unavailable"}}, {Name: "last_connection", Type: field.TypeTime, Nullable: true}, {Name: "volunteer", Type: field.TypeBool, Default: doctor.DefaultVolunteer}, } // DoctorsTable holds the schema information for the "doctors" table. DoctorsTable = &schema.Table{ Name: "doctors", Columns: DoctorsColumns, PrimaryKey: []*schema.Column{DoctorsColumns[0]}, ForeignKeys: []*schema.ForeignKey{}, } // EpidemiologicResultsColumns holds the columns for the "epidemiologic_results" table. EpidemiologicResultsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "visited_places", Type: field.TypeJSON, Nullable: true}, {Name: "infected_family", Type: field.TypeBool, Nullable: true}, {Name: "from_infected_place", Type: field.TypeInt, Nullable: true}, {Name: "to_infected_place", Type: field.TypeInt, Nullable: true}, {Name: "test_epidemiologic", Type: field.TypeUUID, Nullable: true}, } // EpidemiologicResultsTable holds the schema information for the "epidemiologic_results" table. EpidemiologicResultsTable = &schema.Table{ Name: "epidemiologic_results", Columns: EpidemiologicResultsColumns, PrimaryKey: []*schema.Column{EpidemiologicResultsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "epidemiologic_results_tests_epidemiologic", Columns: []*schema.Column{EpidemiologicResultsColumns[5]}, RefColumns: []*schema.Column{TestsColumns[0]}, OnDelete: schema.SetNull, }, }, } // HistoriesColumns holds the columns for the "histories" table. HistoriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "patient_history", Type: field.TypeUUID, Unique: true, Nullable: true}, } // HistoriesTable holds the schema information for the "histories" table. HistoriesTable = &schema.Table{ Name: "histories", Columns: HistoriesColumns, PrimaryKey: []*schema.Column{HistoriesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "histories_patients_history", Columns: []*schema.Column{HistoriesColumns[1]}, RefColumns: []*schema.Column{PatientsColumns[0]}, OnDelete: schema.SetNull, }, }, } // MedicalNotesColumns holds the columns for the "medical_notes" table. MedicalNotesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "at", Type: field.TypeTime}, {Name: "last_change", Type: field.TypeTime}, {Name: "observations", Type: field.TypeJSON}, {Name: "meta", Type: field.TypeJSON, Nullable: true}, {Name: "doctor_notes", Type: field.TypeUUID, Nullable: true}, {Name: "history_notes", Type: field.TypeUUID, Nullable: true}, } // MedicalNotesTable holds the schema information for the "medical_notes" table. MedicalNotesTable = &schema.Table{ Name: "medical_notes", Columns: MedicalNotesColumns, PrimaryKey: []*schema.Column{MedicalNotesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "medical_notes_doctors_notes", Columns: []*schema.Column{MedicalNotesColumns[5]}, RefColumns: []*schema.Column{DoctorsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "medical_notes_histories_notes", Columns: []*schema.Column{MedicalNotesColumns[6]}, RefColumns: []*schema.Column{HistoriesColumns[0]}, OnDelete: schema.SetNull, }, }, } // PatientsColumns holds the columns for the "patients" table. PatientsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "name", Type: field.TypeString}, {Name: "phone", Type: field.TypeString, Unique: true}, {Name: "age", Type: field.TypeInt, Nullable: true}, {Name: "email", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "password", Type: field.TypeString, Nullable: true}, {Name: "facebook_id", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "watson_id", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "first_contact", Type: field.TypeTime}, {Name: "conditions", Type: field.TypeJSON, Nullable: true}, } // PatientsTable holds the schema information for the "patients" table. PatientsTable = &schema.Table{ Name: "patients", Columns: PatientsColumns, PrimaryKey: []*schema.Column{PatientsColumns[0]}, ForeignKeys: []*schema.ForeignKey{}, } // SchedulesColumns holds the columns for the "schedules" table. SchedulesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "patient_schedule", Type: field.TypeUUID, Unique: true, Nullable: true}, } // SchedulesTable holds the schema information for the "schedules" table. SchedulesTable = &schema.Table{ Name: "schedules", Columns: SchedulesColumns, PrimaryKey: []*schema.Column{SchedulesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "schedules_patients_schedule", Columns: []*schema.Column{SchedulesColumns[1]}, RefColumns: []*schema.Column{PatientsColumns[0]}, OnDelete: schema.SetNull, }, }, } // TasksColumns holds the columns for the "tasks" table. TasksColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "title", Type: field.TypeString}, {Name: "start_at", Type: field.TypeTime}, {Name: "ends_at", Type: field.TypeTime}, {Name: "description", Type: field.TypeJSON, Nullable: true}, {Name: "schedule_tasks", Type: field.TypeUUID, Nullable: true}, } // TasksTable holds the schema information for the "tasks" table. TasksTable = &schema.Table{ Name: "tasks", Columns: TasksColumns, PrimaryKey: []*schema.Column{TasksColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "tasks_schedules_tasks", Columns: []*schema.Column{TasksColumns[5]}, RefColumns: []*schema.Column{SchedulesColumns[0]}, OnDelete: schema.SetNull, }, }, } // TaskResponsesColumns holds the columns for the "task_responses" table. TaskResponsesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "at", Type: field.TypeTime}, {Name: "last_change", Type: field.TypeTime}, {Name: "observations", Type: field.TypeJSON}, {Name: "meta", Type: field.TypeJSON, Nullable: true}, {Name: "doctor_responses", Type: field.TypeUUID, Nullable: true}, {Name: "task_responses", Type: field.TypeUUID, Nullable: true}, } // TaskResponsesTable holds the schema information for the "task_responses" table. TaskResponsesTable = &schema.Table{ Name: "task_responses", Columns: TaskResponsesColumns, PrimaryKey: []*schema.Column{TaskResponsesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "task_responses_doctors_responses", Columns: []*schema.Column{TaskResponsesColumns[5]}, RefColumns: []*schema.Column{DoctorsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "task_responses_tasks_responses", Columns: []*schema.Column{TaskResponsesColumns[6]}, RefColumns: []*schema.Column{TasksColumns[0]}, OnDelete: schema.SetNull, }, }, } // TestsColumns holds the columns for the "tests" table. TestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "notes", Type: field.TypeJSON, Nullable: true}, {Name: "history_tests", Type: field.TypeUUID, Nullable: true}, } // TestsTable holds the schema information for the "tests" table. TestsTable = &schema.Table{ Name: "tests", Columns: TestsColumns, PrimaryKey: []*schema.Column{TestsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "tests_histories_tests", Columns: []*schema.Column{TestsColumns[2]}, RefColumns: []*schema.Column{HistoriesColumns[0]}, OnDelete: schema.SetNull, }, }, } // TaskResponsibleColumns holds the columns for the "task_responsible" table. TaskResponsibleColumns = []*schema.Column{ {Name: "task_id", Type: field.TypeUUID}, {Name: "doctor_id", Type: field.TypeUUID}, } // TaskResponsibleTable holds the schema information for the "task_responsible" table. TaskResponsibleTable = &schema.Table{ Name: "task_responsible", Columns: TaskResponsibleColumns, PrimaryKey: []*schema.Column{TaskResponsibleColumns[0], TaskResponsibleColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "task_responsible_task_id", Columns: []*schema.Column{TaskResponsibleColumns[0]}, RefColumns: []*schema.Column{TasksColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "task_responsible_doctor_id", Columns: []*schema.Column{TaskResponsibleColumns[1]}, RefColumns: []*schema.Column{DoctorsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AlertsTable, ClinicalResultsTable, DoctorsTable, EpidemiologicResultsTable, HistoriesTable, MedicalNotesTable, PatientsTable, SchedulesTable, TasksTable, TaskResponsesTable, TestsTable, TaskResponsibleTable, } )
Functions ¶
This section is empty.
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.