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 ( // BundlesColumns holds the columns for the "bundles" table. BundlesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "amount", Type: field.TypeFloat64, Default: 1}, {Name: "item_id", Type: field.TypeInt64}, {Name: "product_id", Type: field.TypeInt64}, } // BundlesTable holds the schema information for the "bundles" table. BundlesTable = &schema.Table{ Name: "bundles", Columns: BundlesColumns, PrimaryKey: []*schema.Column{BundlesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "bundles_items_bundles", Columns: []*schema.Column{BundlesColumns[5]}, RefColumns: []*schema.Column{ItemsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "bundles_products_bundles", Columns: []*schema.Column{BundlesColumns[6]}, RefColumns: []*schema.Column{ProductsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "bundle_product_id_item_id", Unique: false, Columns: []*schema.Column{BundlesColumns[6], BundlesColumns[5]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, }, }, } // InvoicesColumns holds the columns for the "invoices" table. InvoicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "user_id", Type: field.TypeInt64}, {Name: "tenant_id", Type: field.TypeInt64}, {Name: "app_id", Type: field.TypeString}, {Name: "amount", Type: field.TypeInt64}, {Name: "price", Type: field.TypeFloat64, SchemaType: map[string]string{"postgres": "numeric"}}, {Name: "currency", Type: field.TypeString, Size: 3, Default: "KZT"}, {Name: "status", Type: field.TypeEnum, Enums: []string{"CREATED", "PAID", "CANCELED_BY_USER", "CANCELED_BY_VENDOR", "FAILED", "REJECTED", "REVOKED"}, Default: "CREATED"}, {Name: "paid_at", Type: field.TypeTime, Nullable: true}, {Name: "paid_till", Type: field.TypeTime, Nullable: true}, {Name: "is_revoked", Type: field.TypeBool, Default: false}, {Name: "revoked_at", Type: field.TypeTime, Nullable: true}, {Name: "is_revoked_processed", Type: field.TypeBool, Default: false}, {Name: "is_paid_at_processed", Type: field.TypeBool, Default: false}, {Name: "is_paid_till_processed", Type: field.TypeBool, Default: false}, {Name: "external_transaction_id", Type: field.TypeString, Nullable: true}, {Name: "payment_provider", Type: field.TypeEnum, Enums: []string{"APP_STORE", "ONE_VISION_PAYMENT", "TIP_TOP_PAYMENT"}, Default: "APP_STORE"}, {Name: "is_trial", Type: field.TypeBool, Default: false}, {Name: "ttp_subscription_id", Type: field.TypeString, Nullable: true}, {Name: "payment_profile_id", Type: field.TypeInt64, Nullable: true}, {Name: "product_id", Type: field.TypeInt64}, {Name: "subscription_id", Type: field.TypeInt64, Nullable: true}, } // 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_payment_profiles_invoices", Columns: []*schema.Column{InvoicesColumns[19]}, RefColumns: []*schema.Column{PaymentProfilesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "invoices_products_invoices", Columns: []*schema.Column{InvoicesColumns[20]}, RefColumns: []*schema.Column{ProductsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "invoices_subscriptions_invoices", Columns: []*schema.Column{InvoicesColumns[21]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.SetNull, }, }, } // ItemsColumns holds the columns for the "items" table. ItemsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "topic_name", Type: field.TypeString, Unique: true, Nullable: true}, } // ItemsTable holds the schema information for the "items" table. ItemsTable = &schema.Table{ Name: "items", Columns: ItemsColumns, PrimaryKey: []*schema.Column{ItemsColumns[0]}, } // PaymentProfilesColumns holds the columns for the "payment_profiles" table. PaymentProfilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "user_id", Type: field.TypeInt64}, {Name: "pan_masked", Type: field.TypeString}, {Name: "holder", Type: field.TypeString}, {Name: "email", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "phone", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "user_token", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "recurrent_token", Type: field.TypeString, Unique: true, Nullable: true}, } // PaymentProfilesTable holds the schema information for the "payment_profiles" table. PaymentProfilesTable = &schema.Table{ Name: "payment_profiles", Columns: PaymentProfilesColumns, PrimaryKey: []*schema.Column{PaymentProfilesColumns[0]}, } // ProductsColumns holds the columns for the "products" table. ProductsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "app_id", Type: field.TypeString}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "price", Type: field.TypeFloat64, SchemaType: map[string]string{"postgres": "numeric"}}, {Name: "currency", Type: field.TypeString, Size: 3, Default: "KZT"}, {Name: "is_active", Type: field.TypeBool, Default: true}, {Name: "is_limited", Type: field.TypeBool, Default: false}, {Name: "limited_till", Type: field.TypeTime, Nullable: true}, {Name: "left", Type: field.TypeInt64, Default: 0}, {Name: "is_unique", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "unique_limit", Type: field.TypeInt64, Default: 0}, {Name: "is_expiring", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "expiring_time", Type: field.TypeTime, Nullable: true}, {Name: "payment_model", Type: field.TypeEnum, Enums: []string{"ONE_TIME", "RECURRENT"}, Default: "RECURRENT"}, {Name: "product_period", Type: field.TypeEnum, Enums: []string{"day", "week", "month", "year", "unlimited"}, Default: "month"}, } // ProductsTable holds the schema information for the "products" table. ProductsTable = &schema.Table{ Name: "products", Columns: ProductsColumns, PrimaryKey: []*schema.Column{ProductsColumns[0]}, } // ProductReservationsColumns holds the columns for the "product_reservations" table. ProductReservationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "user_id", Type: field.TypeInt64}, {Name: "reserved_quantity", Type: field.TypeInt64, Default: 1}, {Name: "status", Type: field.TypeEnum, Enums: []string{"PENDING", "COMPLETED", "EXPIRED", "CANCELLED"}, Default: "PENDING"}, {Name: "expiration_time", Type: field.TypeTime}, {Name: "invoice_id", Type: field.TypeInt64}, {Name: "product_id", Type: field.TypeInt64}, } // ProductReservationsTable holds the schema information for the "product_reservations" table. ProductReservationsTable = &schema.Table{ Name: "product_reservations", Columns: ProductReservationsColumns, PrimaryKey: []*schema.Column{ProductReservationsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "product_reservations_invoices_reservations", Columns: []*schema.Column{ProductReservationsColumns[7]}, RefColumns: []*schema.Column{InvoicesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "product_reservations_products_reservations", Columns: []*schema.Column{ProductReservationsColumns[8]}, RefColumns: []*schema.Column{ProductsColumns[0]}, OnDelete: schema.NoAction, }, }, } // SubscriptionsColumns holds the columns for the "subscriptions" table. SubscriptionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "user_id", Type: field.TypeInt64}, {Name: "tenant_id", Type: field.TypeInt64}, {Name: "app_id", Type: field.TypeString}, {Name: "product_id", Type: field.TypeInt64}, } // SubscriptionsTable holds the schema information for the "subscriptions" table. SubscriptionsTable = &schema.Table{ Name: "subscriptions", Columns: SubscriptionsColumns, PrimaryKey: []*schema.Column{SubscriptionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "subscriptions_products_subscriptions", Columns: []*schema.Column{SubscriptionsColumns[4]}, RefColumns: []*schema.Column{ProductsColumns[0]}, OnDelete: schema.NoAction, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BundlesTable, InvoicesTable, ItemsTable, PaymentProfilesTable, ProductsTable, ProductReservationsTable, SubscriptionsTable, } )
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.