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 ( // BalancesColumns holds the columns for the "balances" table. BalancesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "total_amount", Type: field.TypeFloat64}, {Name: "available_amount", Type: field.TypeFloat64}, {Name: "entity_id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, } // BalancesTable holds the schema information for the "balances" table. BalancesTable = &schema.Table{ Name: "balances", Columns: BalancesColumns, PrimaryKey: []*schema.Column{BalancesColumns[0]}, } // BidsColumns holds the columns for the "bids" table. BidsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"PENDING", "ACCEPTED", "REJECTED"}, Default: "PENDING"}, {Name: "amount", Type: field.TypeFloat64}, {Name: "accepted_amount", Type: field.TypeFloat64, Default: 0}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "investor_bids", Type: field.TypeUUID}, {Name: "invoice_bids", Type: field.TypeUUID}, } // BidsTable holds the schema information for the "bids" table. BidsTable = &schema.Table{ Name: "bids", Columns: BidsColumns, PrimaryKey: []*schema.Column{BidsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "bids_investors_bids", Columns: []*schema.Column{BidsColumns[6]}, RefColumns: []*schema.Column{InvestorsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "bids_invoices_bids", Columns: []*schema.Column{BidsColumns[7]}, RefColumns: []*schema.Column{InvoicesColumns[0]}, OnDelete: schema.NoAction, }, }, } // InvestorsColumns holds the columns for the "investors" table. InvestorsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "joined_at", Type: field.TypeTime}, {Name: "investor_balance", Type: field.TypeUUID}, } // InvestorsTable holds the schema information for the "investors" table. InvestorsTable = &schema.Table{ Name: "investors", Columns: InvestorsColumns, PrimaryKey: []*schema.Column{InvestorsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "investors_balances_balance", Columns: []*schema.Column{InvestorsColumns[3]}, RefColumns: []*schema.Column{BalancesColumns[0]}, OnDelete: schema.NoAction, }, }, } // InvoicesColumns holds the columns for the "invoices" table. InvoicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "processed"}, Default: "pending"}, {Name: "asking_price", Type: field.TypeFloat64, Default: 0}, {Name: "is_locked", Type: field.TypeBool, Default: false}, {Name: "is_approved", Type: field.TypeBool, Default: false}, {Name: "invoice_number", Type: field.TypeString}, {Name: "invoice_date", Type: field.TypeTime}, {Name: "due_date", Type: field.TypeTime}, {Name: "amount_due", Type: field.TypeFloat64}, {Name: "customer_name", Type: field.TypeString}, {Name: "reference", Type: field.TypeString, Nullable: true}, {Name: "company_name", Type: field.TypeString, Nullable: true}, {Name: "currency", Type: field.TypeString, Default: "GBP"}, {Name: "total_amount", Type: field.TypeFloat64, Nullable: true, Default: 0}, {Name: "total_vat", Type: field.TypeFloat64, Nullable: true, Default: 0}, {Name: "created_at", Type: field.TypeTime}, {Name: "issuer_invoices", Type: field.TypeUUID}, } // InvoicesTable holds the schema information for the "invoices" table. InvoicesTable = &schema.Table{ Name: "invoices", Columns: InvoicesColumns, PrimaryKey: []*schema.Column{InvoicesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "invoices_issuers_invoices", Columns: []*schema.Column{InvoicesColumns[16]}, RefColumns: []*schema.Column{IssuersColumns[0]}, OnDelete: schema.NoAction, }, }, } // InvoiceItemsColumns holds the columns for the "invoice_items" table. InvoiceItemsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "description", Type: field.TypeString}, {Name: "quantity", Type: field.TypeInt}, {Name: "unit_price", Type: field.TypeFloat64}, {Name: "amount", Type: field.TypeFloat64}, {Name: "vat_rate", Type: field.TypeFloat64, Default: 0}, {Name: "vat_amount", Type: field.TypeFloat64, Default: 0}, {Name: "invoice_items", Type: field.TypeUUID, Nullable: true}, } // InvoiceItemsTable holds the schema information for the "invoice_items" table. InvoiceItemsTable = &schema.Table{ Name: "invoice_items", Columns: InvoiceItemsColumns, PrimaryKey: []*schema.Column{InvoiceItemsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "invoice_items_invoices_items", Columns: []*schema.Column{InvoiceItemsColumns[7]}, RefColumns: []*schema.Column{InvoicesColumns[0]}, OnDelete: schema.SetNull, }, }, } // IssuersColumns holds the columns for the "issuers" table. IssuersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "joined_at", Type: field.TypeTime}, {Name: "issuer_balance", Type: field.TypeUUID}, } // IssuersTable holds the schema information for the "issuers" table. IssuersTable = &schema.Table{ Name: "issuers", Columns: IssuersColumns, PrimaryKey: []*schema.Column{IssuersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "issuers_balances_balance", Columns: []*schema.Column{IssuersColumns[3]}, RefColumns: []*schema.Column{BalancesColumns[0]}, OnDelete: schema.NoAction, }, }, } // LedgersColumns holds the columns for the "ledgers" table. LedgersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "resolved"}, Default: "pending"}, {Name: "invoice_id", Type: field.TypeUUID}, {Name: "entity", Type: field.TypeEnum, Enums: []string{"issuer", "investor"}}, {Name: "entity_id", Type: field.TypeUUID}, {Name: "amount", Type: field.TypeFloat64}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, } // LedgersTable holds the schema information for the "ledgers" table. LedgersTable = &schema.Table{ Name: "ledgers", Columns: LedgersColumns, PrimaryKey: []*schema.Column{LedgersColumns[0]}, } // InvestorInvoicesColumns holds the columns for the "investor_invoices" table. InvestorInvoicesColumns = []*schema.Column{ {Name: "investor_id", Type: field.TypeUUID}, {Name: "invoice_id", Type: field.TypeUUID}, } // InvestorInvoicesTable holds the schema information for the "investor_invoices" table. InvestorInvoicesTable = &schema.Table{ Name: "investor_invoices", Columns: InvestorInvoicesColumns, PrimaryKey: []*schema.Column{InvestorInvoicesColumns[0], InvestorInvoicesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "investor_invoices_investor_id", Columns: []*schema.Column{InvestorInvoicesColumns[0]}, RefColumns: []*schema.Column{InvestorsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "investor_invoices_invoice_id", Columns: []*schema.Column{InvestorInvoicesColumns[1]}, RefColumns: []*schema.Column{InvoicesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BalancesTable, BidsTable, InvestorsTable, InvoicesTable, InvoiceItemsTable, IssuersTable, LedgersTable, InvestorInvoicesTable, } )
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.