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 ( // AddonsColumns holds the columns for the "addons" table. AddonsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "lookup_key", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // AddonsTable holds the schema information for the "addons" table. AddonsTable = &schema.Table{ Name: "addons", Columns: AddonsColumns, PrimaryKey: []*schema.Column{AddonsColumns[0]}, Indexes: []*schema.Index{ { Name: "addon_tenant_id_environment_id_lookup_key", Unique: true, Columns: []*schema.Column{AddonsColumns[1], AddonsColumns[7], AddonsColumns[8]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published' AND lookup_key IS NOT NULL AND lookup_key != ''", }, }, }, } // AddonAssociationsColumns holds the columns for the "addon_associations" table. AddonAssociationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "addon_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "start_date", Type: field.TypeTime, Nullable: true}, {Name: "end_date", Type: field.TypeTime, Nullable: true}, {Name: "addon_status", Type: field.TypeString, Default: "active", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "cancellation_reason", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "cancelled_at", Type: field.TypeTime, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // AddonAssociationsTable holds the schema information for the "addon_associations" table. AddonAssociationsTable = &schema.Table{ Name: "addon_associations", Columns: AddonAssociationsColumns, PrimaryKey: []*schema.Column{AddonAssociationsColumns[0]}, Indexes: []*schema.Index{ { Name: "addonassociation_tenant_id_environment_id_entity_id_entity_type_addon_id", Unique: false, Columns: []*schema.Column{AddonAssociationsColumns[1], AddonAssociationsColumns[7], AddonAssociationsColumns[8], AddonAssociationsColumns[9], AddonAssociationsColumns[10]}, }, }, } // AlertLogsColumns holds the columns for the "alert_logs" table. AlertLogsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "parent_entity_type", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "parent_entity_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "alert_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "alert_status", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "alert_info", Type: field.TypeJSON, SchemaType: map[string]string{"postgres": "jsonb"}}, } // AlertLogsTable holds the schema information for the "alert_logs" table. AlertLogsTable = &schema.Table{ Name: "alert_logs", Columns: AlertLogsColumns, PrimaryKey: []*schema.Column{AlertLogsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_alertlogs_entity", Unique: false, Columns: []*schema.Column{AlertLogsColumns[1], AlertLogsColumns[7], AlertLogsColumns[8], AlertLogsColumns[9]}, }, { Name: "idx_alertlogs_type", Unique: false, Columns: []*schema.Column{AlertLogsColumns[1], AlertLogsColumns[7], AlertLogsColumns[12]}, }, { Name: "idx_alertlogs_entity_created_at", Unique: false, Columns: []*schema.Column{AlertLogsColumns[1], AlertLogsColumns[7], AlertLogsColumns[8], AlertLogsColumns[9], AlertLogsColumns[3]}, }, { Name: "idx_alertlogs_entity_parent_created_at", Unique: false, Columns: []*schema.Column{AlertLogsColumns[1], AlertLogsColumns[7], AlertLogsColumns[8], AlertLogsColumns[9], AlertLogsColumns[10], AlertLogsColumns[11], AlertLogsColumns[3]}, }, }, } // AuthsColumns holds the columns for the "auths" table. AuthsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "user_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "provider", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "token", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, } // AuthsTable holds the schema information for the "auths" table. AuthsTable = &schema.Table{ Name: "auths", Columns: AuthsColumns, PrimaryKey: []*schema.Column{AuthsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_auth_user_id_unique", Unique: true, Columns: []*schema.Column{AuthsColumns[1]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "idx_auth_provider", Unique: false, Columns: []*schema.Column{AuthsColumns[2]}, }, { Name: "idx_auth_status", Unique: false, Columns: []*schema.Column{AuthsColumns[4]}, }, { Name: "idx_auth_created_at", Unique: false, Columns: []*schema.Column{AuthsColumns[5]}, }, }, } // BillingSequencesColumns holds the columns for the "billing_sequences" table. BillingSequencesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "last_sequence", Type: field.TypeInt, Default: 0, SchemaType: map[string]string{"postgres": "integer"}}, {Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamp"}}, {Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamp"}}, } // BillingSequencesTable holds the schema information for the "billing_sequences" table. BillingSequencesTable = &schema.Table{ Name: "billing_sequences", Columns: BillingSequencesColumns, PrimaryKey: []*schema.Column{BillingSequencesColumns[0]}, Indexes: []*schema.Index{ { Name: "billingsequence_tenant_id_subscription_id", Unique: true, Columns: []*schema.Column{BillingSequencesColumns[1], BillingSequencesColumns[2]}, }, }, } // ConnectionsColumns holds the columns for the "connections" table. ConnectionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "provider_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "encrypted_secret_data", Type: field.TypeJSON, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "sync_config", Type: field.TypeJSON, Nullable: true}, } // ConnectionsTable holds the schema information for the "connections" table. ConnectionsTable = &schema.Table{ Name: "connections", Columns: ConnectionsColumns, PrimaryKey: []*schema.Column{ConnectionsColumns[0]}, Indexes: []*schema.Index{ { Name: "connection_tenant_id_environment_id_provider_type", Unique: false, Columns: []*schema.Column{ConnectionsColumns[1], ConnectionsColumns[7], ConnectionsColumns[9]}, }, }, } // CostsheetColumns holds the columns for the "costsheet" table. CostsheetColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "meter_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "price_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // CostsheetTable holds the schema information for the "costsheet" table. CostsheetTable = &schema.Table{ Name: "costsheet", Columns: CostsheetColumns, PrimaryKey: []*schema.Column{CostsheetColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "costsheet_meters_costsheet", Columns: []*schema.Column{CostsheetColumns[8]}, RefColumns: []*schema.Column{MetersColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "costsheet_prices_costsheet", Columns: []*schema.Column{CostsheetColumns[9]}, RefColumns: []*schema.Column{PricesColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "costsheet_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{CostsheetColumns[1], CostsheetColumns[7]}, }, { Name: "costsheet_meter_id_price_id", Unique: true, Columns: []*schema.Column{CostsheetColumns[8], CostsheetColumns[9]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, }, } // CouponsColumns holds the columns for the "coupons" table. CouponsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "redeem_after", Type: field.TypeTime, Nullable: true}, {Name: "redeem_before", Type: field.TypeTime, Nullable: true}, {Name: "max_redemptions", Type: field.TypeInt, Nullable: true}, {Name: "total_redemptions", Type: field.TypeInt, Default: 0}, {Name: "rules", Type: field.TypeJSON, Nullable: true}, {Name: "amount_off", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "percentage_off", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(7,4)"}}, {Name: "type", Type: field.TypeString, Default: "fixed", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "cadence", Type: field.TypeString, Default: "once", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "duration_in_periods", Type: field.TypeInt, Nullable: true}, {Name: "currency", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, } // CouponsTable holds the schema information for the "coupons" table. CouponsTable = &schema.Table{ Name: "coupons", Columns: CouponsColumns, PrimaryKey: []*schema.Column{CouponsColumns[0]}, Indexes: []*schema.Index{ { Name: "coupon_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{CouponsColumns[1], CouponsColumns[7]}, }, }, } // CouponApplicationsColumns holds the columns for the "coupon_applications" table. CouponApplicationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "coupon_association_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "applied_at", Type: field.TypeTime}, {Name: "original_price", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "final_price", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "discounted_amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "discount_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "discount_percentage", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(7,4)"}}, {Name: "currency", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "coupon_snapshot", Type: field.TypeJSON, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "coupon_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_line_item_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // CouponApplicationsTable holds the schema information for the "coupon_applications" table. CouponApplicationsTable = &schema.Table{ Name: "coupon_applications", Columns: CouponApplicationsColumns, PrimaryKey: []*schema.Column{CouponApplicationsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "coupon_applications_coupons_coupon_applications", Columns: []*schema.Column{CouponApplicationsColumns[18]}, RefColumns: []*schema.Column{CouponsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "coupon_applications_invoices_coupon_applications", Columns: []*schema.Column{CouponApplicationsColumns[19]}, RefColumns: []*schema.Column{InvoicesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "coupon_applications_invoice_line_items_coupon_applications", Columns: []*schema.Column{CouponApplicationsColumns[20]}, RefColumns: []*schema.Column{InvoiceLineItemsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "coupon_applications_subscriptions_coupon_applications", Columns: []*schema.Column{CouponApplicationsColumns[21]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "couponapplication_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{CouponApplicationsColumns[1], CouponApplicationsColumns[7]}, }, { Name: "couponapplication_tenant_id_environment_id_coupon_id", Unique: false, Columns: []*schema.Column{CouponApplicationsColumns[1], CouponApplicationsColumns[7], CouponApplicationsColumns[18]}, }, { Name: "couponapplication_tenant_id_environment_id_invoice_id", Unique: false, Columns: []*schema.Column{CouponApplicationsColumns[1], CouponApplicationsColumns[7], CouponApplicationsColumns[19]}, }, { Name: "couponapplication_tenant_id_environment_id_invoice_id_invoice_line_item_id", Unique: false, Columns: []*schema.Column{CouponApplicationsColumns[1], CouponApplicationsColumns[7], CouponApplicationsColumns[19], CouponApplicationsColumns[20]}, }, { Name: "couponapplication_tenant_id_environment_id_subscription_id", Unique: false, Columns: []*schema.Column{CouponApplicationsColumns[1], CouponApplicationsColumns[7], CouponApplicationsColumns[21]}, }, { Name: "couponapplication_tenant_id_environment_id_subscription_id_coupon_id", Unique: false, Columns: []*schema.Column{CouponApplicationsColumns[1], CouponApplicationsColumns[7], CouponApplicationsColumns[21], CouponApplicationsColumns[18]}, }, }, } // CouponAssociationsColumns holds the columns for the "coupon_associations" table. CouponAssociationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "coupon_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_line_item_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // CouponAssociationsTable holds the schema information for the "coupon_associations" table. CouponAssociationsTable = &schema.Table{ Name: "coupon_associations", Columns: CouponAssociationsColumns, PrimaryKey: []*schema.Column{CouponAssociationsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "coupon_associations_coupons_coupon_associations", Columns: []*schema.Column{CouponAssociationsColumns[9]}, RefColumns: []*schema.Column{CouponsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "coupon_associations_subscriptions_coupon_associations", Columns: []*schema.Column{CouponAssociationsColumns[10]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "coupon_associations_subscription_line_items_coupon_associations", Columns: []*schema.Column{CouponAssociationsColumns[11]}, RefColumns: []*schema.Column{SubscriptionLineItemsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "couponassociation_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{CouponAssociationsColumns[1], CouponAssociationsColumns[7]}, }, { Name: "couponassociation_tenant_id_environment_id_coupon_id", Unique: false, Columns: []*schema.Column{CouponAssociationsColumns[1], CouponAssociationsColumns[7], CouponAssociationsColumns[9]}, }, { Name: "couponassociation_tenant_id_environment_id_subscription_id", Unique: false, Columns: []*schema.Column{CouponAssociationsColumns[1], CouponAssociationsColumns[7], CouponAssociationsColumns[10]}, }, { Name: "couponassociation_tenant_id_environment_id_subscription_id_subscription_line_item_id", Unique: false, Columns: []*schema.Column{CouponAssociationsColumns[1], CouponAssociationsColumns[7], CouponAssociationsColumns[10], CouponAssociationsColumns[11]}, }, }, } // CreditGrantsColumns holds the columns for the "credit_grants" table. CreditGrantsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "scope", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "credits", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "cadence", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "period", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "period_count", Type: field.TypeInt, Nullable: true}, {Name: "expiration_type", Type: field.TypeString, Default: "NEVER", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "expiration_duration", Type: field.TypeInt, Nullable: true}, {Name: "expiration_duration_unit", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "priority", Type: field.TypeInt, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "plan_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // CreditGrantsTable holds the schema information for the "credit_grants" table. CreditGrantsTable = &schema.Table{ Name: "credit_grants", Columns: CreditGrantsColumns, PrimaryKey: []*schema.Column{CreditGrantsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "credit_grants_plans_credit_grants", Columns: []*schema.Column{CreditGrantsColumns[19]}, RefColumns: []*schema.Column{PlansColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "credit_grants_subscriptions_credit_grants", Columns: []*schema.Column{CreditGrantsColumns[20]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "creditgrant_tenant_id_environment_id_status", Unique: false, Columns: []*schema.Column{CreditGrantsColumns[1], CreditGrantsColumns[7], CreditGrantsColumns[2]}, }, { Name: "idx_plan_id_not_null", Unique: false, Columns: []*schema.Column{CreditGrantsColumns[1], CreditGrantsColumns[7], CreditGrantsColumns[9], CreditGrantsColumns[19]}, Annotation: &entsql.IndexAnnotation{ Where: "plan_id IS NOT NULL", }, }, { Name: "idx_subscription_id_not_null", Unique: false, Columns: []*schema.Column{CreditGrantsColumns[1], CreditGrantsColumns[7], CreditGrantsColumns[9], CreditGrantsColumns[20]}, Annotation: &entsql.IndexAnnotation{ Where: "subscription_id IS NOT NULL", }, }, }, } // CreditGrantApplicationsColumns holds the columns for the "credit_grant_applications" table. CreditGrantApplicationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "credit_grant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "scheduled_for", Type: field.TypeTime}, {Name: "applied_at", Type: field.TypeTime, Nullable: true}, {Name: "period_start", Type: field.TypeTime, Nullable: true}, {Name: "period_end", Type: field.TypeTime, Nullable: true}, {Name: "application_status", Type: field.TypeString, Default: "pending"}, {Name: "credits", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "application_reason", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}}, {Name: "subscription_status_at_application", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "retry_count", Type: field.TypeInt, Default: 0}, {Name: "failure_reason", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, {Name: "metadata", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "idempotency_key", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, } // CreditGrantApplicationsTable holds the schema information for the "credit_grant_applications" table. CreditGrantApplicationsTable = &schema.Table{ Name: "credit_grant_applications", Columns: CreditGrantApplicationsColumns, PrimaryKey: []*schema.Column{CreditGrantApplicationsColumns[0]}, } // CreditNotesColumns holds the columns for the "credit_notes" table. CreditNotesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "customer_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "credit_note_number", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "credit_note_status", Type: field.TypeString, Default: "DRAFT", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "credit_note_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "refund_status", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "reason", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "memo", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "idempotency_key", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, {Name: "voided_at", Type: field.TypeTime, Nullable: true}, {Name: "finalized_at", Type: field.TypeTime, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "total_amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, } // CreditNotesTable holds the schema information for the "credit_notes" table. CreditNotesTable = &schema.Table{ Name: "credit_notes", Columns: CreditNotesColumns, PrimaryKey: []*schema.Column{CreditNotesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tenant_environment_credit_note_number_unique", Unique: true, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[11]}, Annotation: &entsql.IndexAnnotation{ Where: "credit_note_number IS NOT NULL AND credit_note_number != '' AND status = 'published'", }, }, { Name: "creditnote_tenant_id_environment_id_idempotency_key", Unique: false, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[18]}, Annotation: &entsql.IndexAnnotation{ Where: "idempotency_key IS NOT NULL AND idempotency_key != ''", }, }, { Name: "creditnote_tenant_id_environment_id_invoice_id", Unique: false, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[8]}, }, { Name: "creditnote_tenant_id_environment_id_credit_note_status", Unique: false, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[12]}, }, { Name: "creditnote_tenant_id_environment_id_credit_note_type", Unique: false, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[13]}, }, { Name: "creditnote_tenant_id_environment_id_customer_id", Unique: false, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[9]}, }, { Name: "creditnote_tenant_id_environment_id_subscription_id", Unique: false, Columns: []*schema.Column{CreditNotesColumns[1], CreditNotesColumns[7], CreditNotesColumns[10]}, }, }, } // CreditNoteLineItemsColumns holds the columns for the "credit_note_line_items" table. CreditNoteLineItemsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_line_item_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "display_name", Type: field.TypeString}, {Name: "amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "credit_note_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // CreditNoteLineItemsTable holds the schema information for the "credit_note_line_items" table. CreditNoteLineItemsTable = &schema.Table{ Name: "credit_note_line_items", Columns: CreditNoteLineItemsColumns, PrimaryKey: []*schema.Column{CreditNoteLineItemsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "credit_note_line_items_credit_notes_line_items", Columns: []*schema.Column{CreditNoteLineItemsColumns[13]}, RefColumns: []*schema.Column{CreditNotesColumns[0]}, OnDelete: schema.NoAction, }, }, } // CustomersColumns holds the columns for the "customers" table. CustomersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "external_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "email", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "address_line1", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "address_line2", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "address_city", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, {Name: "address_state", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, {Name: "address_postal_code", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "address_country", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(2)"}}, } // CustomersTable holds the schema information for the "customers" table. CustomersTable = &schema.Table{ Name: "customers", Columns: CustomersColumns, PrimaryKey: []*schema.Column{CustomersColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tenant_environment_external_id_unique", Unique: true, Columns: []*schema.Column{CustomersColumns[1], CustomersColumns[7], CustomersColumns[9]}, Annotation: &entsql.IndexAnnotation{ Where: "(external_id IS NOT NULL AND external_id != '') AND status = 'published'", }, }, { Name: "customer_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{CustomersColumns[1], CustomersColumns[7]}, }, { Name: "idx_customer_tenant_environment_email", Unique: false, Columns: []*schema.Column{CustomersColumns[1], CustomersColumns[7], CustomersColumns[11]}, Annotation: &entsql.IndexAnnotation{ Where: "email IS NOT NULL AND email != '' AND status = 'published'", }, }, }, } // EntitlementsColumns holds the columns for the "entitlements" table. EntitlementsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, Nullable: true, Default: "PLAN", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "feature_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "feature_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "is_enabled", Type: field.TypeBool, Default: false}, {Name: "usage_limit", Type: field.TypeInt64, Nullable: true}, {Name: "usage_reset_period", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "is_soft_limit", Type: field.TypeBool, Default: false}, {Name: "static_value", Type: field.TypeString, Nullable: true}, {Name: "display_order", Type: field.TypeInt, Default: 0}, {Name: "addon_entitlements", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // EntitlementsTable holds the schema information for the "entitlements" table. EntitlementsTable = &schema.Table{ Name: "entitlements", Columns: EntitlementsColumns, PrimaryKey: []*schema.Column{EntitlementsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "entitlements_addons_entitlements", Columns: []*schema.Column{EntitlementsColumns[18]}, RefColumns: []*schema.Column{AddonsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "entitlement_tenant_id_environment_id_entity_type_entity_id_feature_id", Unique: true, Columns: []*schema.Column{EntitlementsColumns[1], EntitlementsColumns[7], EntitlementsColumns[8], EntitlementsColumns[9], EntitlementsColumns[10]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "entitlement_tenant_id_environment_id_entity_type_entity_id", Unique: false, Columns: []*schema.Column{EntitlementsColumns[1], EntitlementsColumns[7], EntitlementsColumns[8], EntitlementsColumns[9]}, }, { Name: "entitlement_tenant_id_environment_id_feature_id", Unique: false, Columns: []*schema.Column{EntitlementsColumns[1], EntitlementsColumns[7], EntitlementsColumns[10]}, }, }, } // EntityIntegrationMappingsColumns holds the columns for the "entity_integration_mappings" table. EntityIntegrationMappingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "provider_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "provider_entity_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, } // EntityIntegrationMappingsTable holds the schema information for the "entity_integration_mappings" table. EntityIntegrationMappingsTable = &schema.Table{ Name: "entity_integration_mappings", Columns: EntityIntegrationMappingsColumns, PrimaryKey: []*schema.Column{EntityIntegrationMappingsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_entity_integration_mapping_unique", Unique: true, Columns: []*schema.Column{EntityIntegrationMappingsColumns[1], EntityIntegrationMappingsColumns[7], EntityIntegrationMappingsColumns[9], EntityIntegrationMappingsColumns[8], EntityIntegrationMappingsColumns[10]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "entityintegrationmapping_provider_type_provider_entity_id", Unique: false, Columns: []*schema.Column{EntityIntegrationMappingsColumns[10], EntityIntegrationMappingsColumns[11]}, }, }, } // EnvironmentsColumns holds the columns for the "environments" table. EnvironmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, } // EnvironmentsTable holds the schema information for the "environments" table. EnvironmentsTable = &schema.Table{ Name: "environments", Columns: EnvironmentsColumns, PrimaryKey: []*schema.Column{EnvironmentsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_environment_tenant_id_type", Unique: false, Columns: []*schema.Column{EnvironmentsColumns[1], EnvironmentsColumns[8]}, }, { Name: "idx_environment_tenant_status", Unique: false, Columns: []*schema.Column{EnvironmentsColumns[1], EnvironmentsColumns[2]}, }, { Name: "idx_environment_tenant_created_at", Unique: false, Columns: []*schema.Column{EnvironmentsColumns[1], EnvironmentsColumns[3]}, }, }, } // FeaturesColumns holds the columns for the "features" table. FeaturesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "lookup_key", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "meter_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "unit_singular", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "unit_plural", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "alert_settings", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // FeaturesTable holds the schema information for the "features" table. FeaturesTable = &schema.Table{ Name: "features", Columns: FeaturesColumns, PrimaryKey: []*schema.Column{FeaturesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_feature_tenant_env_lookup_key_unique", Unique: true, Columns: []*schema.Column{FeaturesColumns[1], FeaturesColumns[7], FeaturesColumns[8]}, Annotation: &entsql.IndexAnnotation{ Where: "(lookup_key IS NOT NULL AND lookup_key != '') AND status = 'published'", }, }, { Name: "idx_feature_tenant_env_meter_id", Unique: false, Columns: []*schema.Column{FeaturesColumns[1], FeaturesColumns[7], FeaturesColumns[12]}, Annotation: &entsql.IndexAnnotation{ Where: "meter_id IS NOT NULL", }, }, { Name: "idx_feature_tenant_env_type", Unique: false, Columns: []*schema.Column{FeaturesColumns[1], FeaturesColumns[7], FeaturesColumns[11]}, }, { Name: "idx_feature_tenant_env_status", Unique: false, Columns: []*schema.Column{FeaturesColumns[1], FeaturesColumns[7], FeaturesColumns[2]}, }, { Name: "idx_feature_tenant_env_created_at", Unique: false, Columns: []*schema.Column{FeaturesColumns[1], FeaturesColumns[7], FeaturesColumns[3]}, }, }, } // InvoicesColumns holds the columns for the "invoices" table. InvoicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "customer_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_status", Type: field.TypeString, Default: "DRAFT", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "payment_status", Type: field.TypeString, Default: "PENDING", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "amount_due", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "amount_paid", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "amount_remaining", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "subtotal", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "adjustment_amount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "refunded_amount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "total_tax", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "total_discount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "total", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "due_date", Type: field.TypeTime, Nullable: true}, {Name: "paid_at", Type: field.TypeTime, Nullable: true}, {Name: "voided_at", Type: field.TypeTime, Nullable: true}, {Name: "finalized_at", Type: field.TypeTime, Nullable: true}, {Name: "billing_period", Type: field.TypeString, Nullable: true}, {Name: "period_start", Type: field.TypeTime, Nullable: true}, {Name: "period_end", Type: field.TypeTime, Nullable: true}, {Name: "invoice_pdf_url", Type: field.TypeString, Nullable: true}, {Name: "billing_reason", Type: field.TypeString, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "version", Type: field.TypeInt, Default: 1}, {Name: "invoice_number", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "billing_sequence", Type: field.TypeInt, Nullable: true, SchemaType: map[string]string{"postgres": "integer"}}, {Name: "idempotency_key", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, } // InvoicesTable holds the schema information for the "invoices" table. InvoicesTable = &schema.Table{ Name: "invoices", Columns: InvoicesColumns, PrimaryKey: []*schema.Column{InvoicesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tenant_customer_status", Unique: false, Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[8], InvoicesColumns[11], InvoicesColumns[12], InvoicesColumns[2]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "idx_tenant_subscription_status", Unique: false, Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[9], InvoicesColumns[11], InvoicesColumns[12], InvoicesColumns[2]}, }, { Name: "idx_tenant_type_status", Unique: false, Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[10], InvoicesColumns[11], InvoicesColumns[12], InvoicesColumns[2]}, }, { Name: "idx_tenant_due_date_status", Unique: false, Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[24], InvoicesColumns[11], InvoicesColumns[12], InvoicesColumns[2]}, }, { Name: "idx_tenant_environment_invoice_number_unique", Unique: true, Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[35]}, Annotation: &entsql.IndexAnnotation{ Where: "invoice_number IS NOT NULL AND invoice_number != '' AND status = 'published'", }, }, { Name: "idx_tenant_environment_idempotency_key_unique", Unique: true, Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[37]}, Annotation: &entsql.IndexAnnotation{ Where: "idempotency_key IS NOT NULL", }, }, { Name: "idx_subscription_period_unique", Unique: false, Columns: []*schema.Column{InvoicesColumns[9], InvoicesColumns[29], InvoicesColumns[30]}, Annotation: &entsql.IndexAnnotation{ Where: "invoice_status != 'VOIDED' AND subscription_id IS NOT NULL", }, }, }, } // InvoiceLineItemsColumns holds the columns for the "invoice_line_items" table. InvoiceLineItemsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "customer_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "plan_display_name", Type: field.TypeString, Nullable: true}, {Name: "price_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "price_type", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "meter_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "meter_display_name", Type: field.TypeString, Nullable: true}, {Name: "price_unit_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "price_unit", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "price_unit_amount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "display_name", Type: field.TypeString, Nullable: true}, {Name: "amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "quantity", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "period_start", Type: field.TypeTime, Nullable: true}, {Name: "period_end", Type: field.TypeTime, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "invoice_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // InvoiceLineItemsTable holds the schema information for the "invoice_line_items" table. InvoiceLineItemsTable = &schema.Table{ Name: "invoice_line_items", Columns: InvoiceLineItemsColumns, PrimaryKey: []*schema.Column{InvoiceLineItemsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "invoice_line_items_invoices_line_items", Columns: []*schema.Column{InvoiceLineItemsColumns[27]}, RefColumns: []*schema.Column{InvoicesColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "invoicelineitem_tenant_id_environment_id_invoice_id_status", Unique: false, Columns: []*schema.Column{InvoiceLineItemsColumns[1], InvoiceLineItemsColumns[7], InvoiceLineItemsColumns[27], InvoiceLineItemsColumns[2]}, }, { Name: "invoicelineitem_tenant_id_environment_id_customer_id_status", Unique: false, Columns: []*schema.Column{InvoiceLineItemsColumns[1], InvoiceLineItemsColumns[7], InvoiceLineItemsColumns[8], InvoiceLineItemsColumns[2]}, }, { Name: "invoicelineitem_tenant_id_environment_id_subscription_id_status", Unique: false, Columns: []*schema.Column{InvoiceLineItemsColumns[1], InvoiceLineItemsColumns[7], InvoiceLineItemsColumns[9], InvoiceLineItemsColumns[2]}, }, { Name: "invoicelineitem_tenant_id_environment_id_price_id_status", Unique: false, Columns: []*schema.Column{InvoiceLineItemsColumns[1], InvoiceLineItemsColumns[7], InvoiceLineItemsColumns[13], InvoiceLineItemsColumns[2]}, }, { Name: "invoicelineitem_tenant_id_environment_id_meter_id_status", Unique: false, Columns: []*schema.Column{InvoiceLineItemsColumns[1], InvoiceLineItemsColumns[7], InvoiceLineItemsColumns[15], InvoiceLineItemsColumns[2]}, }, { Name: "invoicelineitem_period_start_period_end", Unique: false, Columns: []*schema.Column{InvoiceLineItemsColumns[24], InvoiceLineItemsColumns[25]}, }, }, } // InvoiceSequencesColumns holds the columns for the "invoice_sequences" table. InvoiceSequencesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "environment_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "year_month", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(6)"}}, {Name: "last_value", Type: field.TypeInt64, Default: 0, SchemaType: map[string]string{"postgres": "bigint"}}, {Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamp"}}, {Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamp"}}, } // InvoiceSequencesTable holds the schema information for the "invoice_sequences" table. InvoiceSequencesTable = &schema.Table{ Name: "invoice_sequences", Columns: InvoiceSequencesColumns, PrimaryKey: []*schema.Column{InvoiceSequencesColumns[0]}, Indexes: []*schema.Index{ { Name: "invoicesequence_tenant_id_environment_id_year_month", Unique: true, Columns: []*schema.Column{InvoiceSequencesColumns[1], InvoiceSequencesColumns[2], InvoiceSequencesColumns[3]}, }, }, } // MetersColumns holds the columns for the "meters" table. MetersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "event_name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "aggregation", Type: field.TypeJSON}, {Name: "filters", Type: field.TypeJSON}, {Name: "reset_usage", Type: field.TypeString, Default: "BILLING_PERIOD", SchemaType: map[string]string{"postgres": "varchar(20)"}}, } // MetersTable holds the schema information for the "meters" table. MetersTable = &schema.Table{ Name: "meters", Columns: MetersColumns, PrimaryKey: []*schema.Column{MetersColumns[0]}, Indexes: []*schema.Index{ { Name: "meter_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{MetersColumns[1], MetersColumns[7]}, }, }, } // PaymentsColumns holds the columns for the "payments" table. PaymentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "idempotency_key", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "destination_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "destination_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "payment_method_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "payment_method_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "payment_gateway", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "gateway_payment_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "gateway_tracking_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "gateway_metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "payment_status", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "track_attempts", Type: field.TypeBool, Default: false}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "succeeded_at", Type: field.TypeTime, Nullable: true}, {Name: "failed_at", Type: field.TypeTime, Nullable: true}, {Name: "refunded_at", Type: field.TypeTime, Nullable: true}, {Name: "recorded_at", Type: field.TypeTime, Nullable: true}, {Name: "error_message", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, } // PaymentsTable holds the schema information for the "payments" table. PaymentsTable = &schema.Table{ Name: "payments", Columns: PaymentsColumns, PrimaryKey: []*schema.Column{PaymentsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tenant_destination_status", Unique: false, Columns: []*schema.Column{PaymentsColumns[1], PaymentsColumns[7], PaymentsColumns[9], PaymentsColumns[10], PaymentsColumns[19], PaymentsColumns[2]}, }, { Name: "idx_tenant_payment_method_status", Unique: false, Columns: []*schema.Column{PaymentsColumns[1], PaymentsColumns[7], PaymentsColumns[11], PaymentsColumns[12], PaymentsColumns[19], PaymentsColumns[2]}, }, { Name: "idx_tenant_gateway_payment", Unique: false, Columns: []*schema.Column{PaymentsColumns[1], PaymentsColumns[7], PaymentsColumns[13], PaymentsColumns[14]}, Annotation: &entsql.IndexAnnotation{ Where: "payment_gateway IS NOT NULL AND gateway_payment_id IS NOT NULL", }, }, }, } // PaymentAttemptsColumns holds the columns for the "payment_attempts" table. PaymentAttemptsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "payment_status", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "attempt_number", Type: field.TypeInt, Default: 1, SchemaType: map[string]string{"postgres": "integer"}}, {Name: "gateway_attempt_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "error_message", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "payment_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // PaymentAttemptsTable holds the schema information for the "payment_attempts" table. PaymentAttemptsTable = &schema.Table{ Name: "payment_attempts", Columns: PaymentAttemptsColumns, PrimaryKey: []*schema.Column{PaymentAttemptsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "payment_attempts_payments_attempts", Columns: []*schema.Column{PaymentAttemptsColumns[13]}, RefColumns: []*schema.Column{PaymentsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "idx_payment_attempt_number_unique", Unique: true, Columns: []*schema.Column{PaymentAttemptsColumns[13], PaymentAttemptsColumns[9]}, }, { Name: "idx_payment_attempt_status", Unique: false, Columns: []*schema.Column{PaymentAttemptsColumns[13], PaymentAttemptsColumns[2]}, }, { Name: "idx_gateway_attempt", Unique: false, Columns: []*schema.Column{PaymentAttemptsColumns[10]}, Annotation: &entsql.IndexAnnotation{ Where: "gateway_attempt_id IS NOT NULL", }, }, }, } // PlansColumns holds the columns for the "plans" table. PlansColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "lookup_key", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "display_order", Type: field.TypeInt, Default: 0}, } // PlansTable holds the schema information for the "plans" table. PlansTable = &schema.Table{ Name: "plans", Columns: PlansColumns, PrimaryKey: []*schema.Column{PlansColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tenant_environment_lookup_key", Unique: true, Columns: []*schema.Column{PlansColumns[1], PlansColumns[7], PlansColumns[9]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published' AND lookup_key IS NOT NULL AND lookup_key != ''", }, }, { Name: "plan_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{PlansColumns[1], PlansColumns[7]}, }, }, } // PricesColumns holds the columns for the "prices" table. PricesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "amount", Type: field.TypeFloat64, SchemaType: map[string]string{"postgres": "numeric(25,15)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "display_amount", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "price_unit_type", Type: field.TypeString, Default: "FIAT", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "price_unit", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "price_unit_amount", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(25,15)"}}, {Name: "display_price_unit_amount", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "conversion_rate", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(25,15)"}}, {Name: "type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "billing_period", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "billing_period_count", Type: field.TypeInt}, {Name: "billing_model", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "billing_cadence", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "invoice_cadence", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "trial_period", Type: field.TypeInt, Default: 0}, {Name: "meter_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "filter_values", Type: field.TypeJSON, Nullable: true}, {Name: "tier_mode", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "tiers", Type: field.TypeJSON, Nullable: true}, {Name: "price_unit_tiers", Type: field.TypeJSON, Nullable: true}, {Name: "transform_quantity", Type: field.TypeJSON, Nullable: true}, {Name: "lookup_key", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "entity_type", Type: field.TypeString, Nullable: true, Default: "PLAN", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "entity_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "parent_price_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "start_date", Type: field.TypeTime, Nullable: true}, {Name: "end_date", Type: field.TypeTime, Nullable: true}, {Name: "addon_prices", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "price_unit_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // PricesTable holds the schema information for the "prices" table. PricesTable = &schema.Table{ Name: "prices", Columns: PricesColumns, PrimaryKey: []*schema.Column{PricesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "prices_addons_prices", Columns: []*schema.Column{PricesColumns[37]}, RefColumns: []*schema.Column{AddonsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "prices_price_unit_price_unit_edge", Columns: []*schema.Column{PricesColumns[38]}, RefColumns: []*schema.Column{PriceUnitColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "price_tenant_id_environment_id_lookup_key", Unique: true, Columns: []*schema.Column{PricesColumns[1], PricesColumns[7], PricesColumns[29]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published' AND lookup_key IS NOT NULL AND lookup_key != ''", }, }, { Name: "price_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{PricesColumns[1], PricesColumns[7]}, }, { Name: "price_start_date_end_date", Unique: false, Columns: []*schema.Column{PricesColumns[35], PricesColumns[36]}, }, }, } // PriceUnitColumns holds the columns for the "price_unit" table. PriceUnitColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "code", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "symbol", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "base_currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "conversion_rate", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(10,5)"}}, {Name: "precision", Type: field.TypeInt, Default: 0}, } // PriceUnitTable holds the schema information for the "price_unit" table. PriceUnitTable = &schema.Table{ Name: "price_unit", Columns: PriceUnitColumns, PrimaryKey: []*schema.Column{PriceUnitColumns[0]}, Indexes: []*schema.Index{ { Name: "priceunit_code_tenant_id_environment_id", Unique: true, Columns: []*schema.Column{PriceUnitColumns[9], PriceUnitColumns[1], PriceUnitColumns[7]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "priceunit_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{PriceUnitColumns[1], PriceUnitColumns[7]}, }, }, } // ScheduledTasksColumns holds the columns for the "scheduled_tasks" table. ScheduledTasksColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "connection_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "interval", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "enabled", Type: field.TypeBool, Default: true}, {Name: "job_config", Type: field.TypeJSON, Nullable: true}, {Name: "temporal_schedule_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, } // ScheduledTasksTable holds the schema information for the "scheduled_tasks" table. ScheduledTasksTable = &schema.Table{ Name: "scheduled_tasks", Columns: ScheduledTasksColumns, PrimaryKey: []*schema.Column{ScheduledTasksColumns[0]}, Indexes: []*schema.Index{ { Name: "scheduledtask_tenant_id_environment_id_enabled", Unique: false, Columns: []*schema.Column{ScheduledTasksColumns[1], ScheduledTasksColumns[7], ScheduledTasksColumns[11]}, }, { Name: "scheduledtask_connection_id_enabled", Unique: false, Columns: []*schema.Column{ScheduledTasksColumns[8], ScheduledTasksColumns[11]}, }, { Name: "scheduledtask_entity_type_interval_enabled", Unique: false, Columns: []*schema.Column{ScheduledTasksColumns[9], ScheduledTasksColumns[10], ScheduledTasksColumns[11]}, }, { Name: "scheduledtask_connection_id_entity_type_status", Unique: false, Columns: []*schema.Column{ScheduledTasksColumns[8], ScheduledTasksColumns[9], ScheduledTasksColumns[2]}, }, }, } // SecretsColumns holds the columns for the "secrets" table. SecretsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString}, {Name: "type", Type: field.TypeString}, {Name: "provider", Type: field.TypeString}, {Name: "value", Type: field.TypeString, Nullable: true}, {Name: "display_id", Type: field.TypeString, Nullable: true}, {Name: "permissions", Type: field.TypeJSON, Nullable: true}, {Name: "expires_at", Type: field.TypeTime, Nullable: true}, {Name: "last_used_at", Type: field.TypeTime, Nullable: true}, {Name: "provider_data", Type: field.TypeJSON, Nullable: true}, } // SecretsTable holds the schema information for the "secrets" table. SecretsTable = &schema.Table{ Name: "secrets", Columns: SecretsColumns, PrimaryKey: []*schema.Column{SecretsColumns[0]}, Indexes: []*schema.Index{ { Name: "secret_type_value_status", Unique: false, Columns: []*schema.Column{SecretsColumns[9], SecretsColumns[11], SecretsColumns[2]}, }, { Name: "secret_tenant_id_environment_id_type_status", Unique: false, Columns: []*schema.Column{SecretsColumns[1], SecretsColumns[7], SecretsColumns[9], SecretsColumns[2]}, }, { Name: "secret_tenant_id_environment_id_provider_status", Unique: false, Columns: []*schema.Column{SecretsColumns[1], SecretsColumns[7], SecretsColumns[10], SecretsColumns[2]}, }, }, } // SettingsColumns holds the columns for the "settings" table. SettingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "key", Type: field.TypeString}, {Name: "value", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // SettingsTable holds the schema information for the "settings" table. SettingsTable = &schema.Table{ Name: "settings", Columns: SettingsColumns, PrimaryKey: []*schema.Column{SettingsColumns[0]}, Indexes: []*schema.Index{ { Name: "settings_tenant_id_environment_id_status_key", Unique: true, Columns: []*schema.Column{SettingsColumns[1], SettingsColumns[7], SettingsColumns[2], SettingsColumns[8]}, }, }, } // SubscriptionsColumns holds the columns for the "subscriptions" table. SubscriptionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "lookup_key", Type: field.TypeString, Nullable: true}, {Name: "customer_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "plan_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "subscription_status", Type: field.TypeString, Default: "active", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "billing_anchor", Type: field.TypeTime}, {Name: "start_date", Type: field.TypeTime}, {Name: "end_date", Type: field.TypeTime, Nullable: true}, {Name: "current_period_start", Type: field.TypeTime}, {Name: "current_period_end", Type: field.TypeTime}, {Name: "cancelled_at", Type: field.TypeTime, Nullable: true}, {Name: "cancel_at", Type: field.TypeTime, Nullable: true}, {Name: "cancel_at_period_end", Type: field.TypeBool, Default: false}, {Name: "trial_start", Type: field.TypeTime, Nullable: true}, {Name: "trial_end", Type: field.TypeTime, Nullable: true}, {Name: "billing_cadence", Type: field.TypeString}, {Name: "billing_period", Type: field.TypeString}, {Name: "billing_period_count", Type: field.TypeInt, Default: 1}, {Name: "version", Type: field.TypeInt, Default: 1}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "pause_status", Type: field.TypeString, Default: "none", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "active_pause_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "billing_cycle", Type: field.TypeString, Default: "anniversary"}, {Name: "commitment_amount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,6)"}}, {Name: "overage_factor", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(10,6)"}}, {Name: "payment_behavior", Type: field.TypeEnum, Enums: []string{"allow_incomplete", "default_incomplete", "error_if_incomplete", "default_active"}, Default: "default_active"}, {Name: "collection_method", Type: field.TypeEnum, Enums: []string{"charge_automatically", "send_invoice"}, Default: "charge_automatically"}, {Name: "gateway_payment_method_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "customer_timezone", Type: field.TypeString, Default: "UTC"}, {Name: "proration_behavior", Type: field.TypeString, Default: "none"}, } // SubscriptionsTable holds the schema information for the "subscriptions" table. SubscriptionsTable = &schema.Table{ Name: "subscriptions", Columns: SubscriptionsColumns, PrimaryKey: []*schema.Column{SubscriptionsColumns[0]}, Indexes: []*schema.Index{ { Name: "subscription_tenant_id_environment_id_customer_id_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[9], SubscriptionsColumns[2]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "subscription_tenant_id_environment_id_plan_id_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[10], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_subscription_status_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[11], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_current_period_end_subscription_status_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[17], SubscriptionsColumns[11], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_pause_status_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[28], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_active_pause_id_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[29], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_payment_behavior_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[33], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_collection_method_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[34], SubscriptionsColumns[2]}, }, { Name: "subscription_tenant_id_environment_id_subscription_status_collection_method_status", Unique: false, Columns: []*schema.Column{SubscriptionsColumns[1], SubscriptionsColumns[7], SubscriptionsColumns[11], SubscriptionsColumns[34], SubscriptionsColumns[2]}, Annotation: &entsql.IndexAnnotation{ Where: "subscription_status IN ('incomplete', 'past_due')", }, }, }, } // SubscriptionLineItemsColumns holds the columns for the "subscription_line_items" table. SubscriptionLineItemsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "customer_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, Default: "plan", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "plan_display_name", Type: field.TypeString, Nullable: true}, {Name: "price_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "price_type", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "meter_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "meter_display_name", Type: field.TypeString, Nullable: true}, {Name: "price_unit_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "price_unit", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "display_name", Type: field.TypeString, Nullable: true}, {Name: "quantity", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "billing_period", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "invoice_cadence", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "trial_period", Type: field.TypeInt, Default: 0}, {Name: "start_date", Type: field.TypeTime, Nullable: true}, {Name: "end_date", Type: field.TypeTime, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "subscription_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // SubscriptionLineItemsTable holds the schema information for the "subscription_line_items" table. SubscriptionLineItemsTable = &schema.Table{ Name: "subscription_line_items", Columns: SubscriptionLineItemsColumns, PrimaryKey: []*schema.Column{SubscriptionLineItemsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "subscription_line_items_subscriptions_line_items", Columns: []*schema.Column{SubscriptionLineItemsColumns[27]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "subscriptionlineitem_tenant_id_environment_id_subscription_id_status", Unique: false, Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[27], SubscriptionLineItemsColumns[2]}, }, { Name: "subscriptionlineitem_tenant_id_environment_id_customer_id_status", Unique: false, Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[8], SubscriptionLineItemsColumns[2]}, }, { Name: "subscriptionlineitem_tenant_id_environment_id_entity_id_entity_type_status", Unique: false, Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[9], SubscriptionLineItemsColumns[10], SubscriptionLineItemsColumns[2]}, }, { Name: "subscriptionlineitem_tenant_id_environment_id_price_id_status", Unique: false, Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[12], SubscriptionLineItemsColumns[2]}, }, { Name: "subscriptionlineitem_tenant_id_environment_id_meter_id_status", Unique: false, Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[14], SubscriptionLineItemsColumns[2]}, }, { Name: "subscriptionlineitem_start_date_end_date", Unique: false, Columns: []*schema.Column{SubscriptionLineItemsColumns[24], SubscriptionLineItemsColumns[25]}, }, }, } // SubscriptionPausesColumns holds the columns for the "subscription_pauses" table. SubscriptionPausesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "pause_status", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "pause_mode", Type: field.TypeString, Default: "scheduled", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "resume_mode", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "pause_start", Type: field.TypeTime}, {Name: "pause_end", Type: field.TypeTime, Nullable: true}, {Name: "resumed_at", Type: field.TypeTime, Nullable: true}, {Name: "original_period_start", Type: field.TypeTime}, {Name: "original_period_end", Type: field.TypeTime}, {Name: "reason", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "subscription_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // SubscriptionPausesTable holds the schema information for the "subscription_pauses" table. SubscriptionPausesTable = &schema.Table{ Name: "subscription_pauses", Columns: SubscriptionPausesColumns, PrimaryKey: []*schema.Column{SubscriptionPausesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "subscription_pauses_subscriptions_pauses", Columns: []*schema.Column{SubscriptionPausesColumns[18]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "subscriptionpause_tenant_id_environment_id_subscription_id_status", Unique: false, Columns: []*schema.Column{SubscriptionPausesColumns[1], SubscriptionPausesColumns[7], SubscriptionPausesColumns[18], SubscriptionPausesColumns[2]}, }, { Name: "subscriptionpause_tenant_id_environment_id_pause_start_status", Unique: false, Columns: []*schema.Column{SubscriptionPausesColumns[1], SubscriptionPausesColumns[7], SubscriptionPausesColumns[11], SubscriptionPausesColumns[2]}, }, { Name: "subscriptionpause_tenant_id_environment_id_pause_end_status", Unique: false, Columns: []*schema.Column{SubscriptionPausesColumns[1], SubscriptionPausesColumns[7], SubscriptionPausesColumns[12], SubscriptionPausesColumns[2]}, }, }, } // SubscriptionSchedulesColumns holds the columns for the "subscription_schedules" table. SubscriptionSchedulesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "schedule_status", Type: field.TypeString, Default: "ACTIVE"}, {Name: "current_phase_index", Type: field.TypeInt, Default: 0}, {Name: "end_behavior", Type: field.TypeString, Default: "RELEASE"}, {Name: "start_date", Type: field.TypeTime}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "subscription_id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // SubscriptionSchedulesTable holds the schema information for the "subscription_schedules" table. SubscriptionSchedulesTable = &schema.Table{ Name: "subscription_schedules", Columns: SubscriptionSchedulesColumns, PrimaryKey: []*schema.Column{SubscriptionSchedulesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "subscription_schedules_subscriptions_schedule", Columns: []*schema.Column{SubscriptionSchedulesColumns[13]}, RefColumns: []*schema.Column{SubscriptionsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "subscriptionschedule_tenant_id_environment_id_subscription_id", Unique: false, Columns: []*schema.Column{SubscriptionSchedulesColumns[1], SubscriptionSchedulesColumns[7], SubscriptionSchedulesColumns[13]}, }, { Name: "subscriptionschedule_tenant_id_environment_id_subscription_id_schedule_status", Unique: false, Columns: []*schema.Column{SubscriptionSchedulesColumns[1], SubscriptionSchedulesColumns[7], SubscriptionSchedulesColumns[13], SubscriptionSchedulesColumns[8]}, }, }, } // SubscriptionSchedulePhasesColumns holds the columns for the "subscription_schedule_phases" table. SubscriptionSchedulePhasesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "phase_index", Type: field.TypeInt}, {Name: "start_date", Type: field.TypeTime}, {Name: "end_date", Type: field.TypeTime, Nullable: true}, {Name: "commitment_amount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,6)"}}, {Name: "overage_factor", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,6)"}}, {Name: "line_items", Type: field.TypeJSON, Nullable: true}, {Name: "credit_grants", Type: field.TypeJSON, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "schedule_id", Type: field.TypeString}, } // SubscriptionSchedulePhasesTable holds the schema information for the "subscription_schedule_phases" table. SubscriptionSchedulePhasesTable = &schema.Table{ Name: "subscription_schedule_phases", Columns: SubscriptionSchedulePhasesColumns, PrimaryKey: []*schema.Column{SubscriptionSchedulePhasesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "subscription_schedule_phases_subscription_schedules_phases", Columns: []*schema.Column{SubscriptionSchedulePhasesColumns[16]}, RefColumns: []*schema.Column{SubscriptionSchedulesColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "subscriptionschedulephase_tenant_id_environment_id_schedule_id_phase_index", Unique: true, Columns: []*schema.Column{SubscriptionSchedulePhasesColumns[1], SubscriptionSchedulePhasesColumns[7], SubscriptionSchedulePhasesColumns[16], SubscriptionSchedulePhasesColumns[8]}, }, { Name: "subscriptionschedulephase_tenant_id_environment_id_start_date", Unique: false, Columns: []*schema.Column{SubscriptionSchedulePhasesColumns[1], SubscriptionSchedulePhasesColumns[7], SubscriptionSchedulePhasesColumns[9]}, }, }, } // TasksColumns holds the columns for the "tasks" table. TasksColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "task_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "scheduled_task_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "workflow_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "file_url", Type: field.TypeString, Default: "", SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "file_name", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "file_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "task_status", Type: field.TypeString, Default: "PENDING", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "total_records", Type: field.TypeInt, Nullable: true}, {Name: "processed_records", Type: field.TypeInt, Default: 0}, {Name: "successful_records", Type: field.TypeInt, Default: 0}, {Name: "failed_records", Type: field.TypeInt, Default: 0}, {Name: "error_summary", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "started_at", Type: field.TypeTime, Nullable: true}, {Name: "completed_at", Type: field.TypeTime, Nullable: true}, {Name: "failed_at", Type: field.TypeTime, Nullable: true}, } // TasksTable holds the schema information for the "tasks" table. TasksTable = &schema.Table{ Name: "tasks", Columns: TasksColumns, PrimaryKey: []*schema.Column{TasksColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tasks_tenant_env_type_status", Unique: false, Columns: []*schema.Column{TasksColumns[1], TasksColumns[7], TasksColumns[8], TasksColumns[9], TasksColumns[2]}, }, { Name: "idx_tasks_tenant_env_user", Unique: false, Columns: []*schema.Column{TasksColumns[1], TasksColumns[7], TasksColumns[5], TasksColumns[2]}, }, { Name: "idx_tasks_tenant_env_task_status", Unique: false, Columns: []*schema.Column{TasksColumns[1], TasksColumns[7], TasksColumns[15], TasksColumns[2]}, }, }, } // TaxAppliedsColumns holds the columns for the "tax_applieds" table. TaxAppliedsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tax_rate_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tax_association_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "taxable_amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(15,6)"}}, {Name: "tax_amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(15,6)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "applied_at", Type: field.TypeTime}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "idempotency_key", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // TaxAppliedsTable holds the schema information for the "tax_applieds" table. TaxAppliedsTable = &schema.Table{ Name: "tax_applieds", Columns: TaxAppliedsColumns, PrimaryKey: []*schema.Column{TaxAppliedsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_entity_tax_rate_id", Unique: true, Columns: []*schema.Column{TaxAppliedsColumns[1], TaxAppliedsColumns[7], TaxAppliedsColumns[9], TaxAppliedsColumns[10], TaxAppliedsColumns[8]}, }, { Name: "idx_entity_tax_association_lookup", Unique: false, Columns: []*schema.Column{TaxAppliedsColumns[1], TaxAppliedsColumns[7], TaxAppliedsColumns[9], TaxAppliedsColumns[10]}, }, }, } // TaxAssociationsColumns holds the columns for the "tax_associations" table. TaxAssociationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tax_rate_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_type", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "entity_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "priority", Type: field.TypeInt, Default: 100, SchemaType: map[string]string{"postgres": "integer"}}, {Name: "auto_apply", Type: field.TypeBool, Default: true}, {Name: "currency", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(100)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // TaxAssociationsTable holds the schema information for the "tax_associations" table. TaxAssociationsTable = &schema.Table{ Name: "tax_associations", Columns: TaxAssociationsColumns, PrimaryKey: []*schema.Column{TaxAssociationsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_entity_lookup_active", Unique: false, Columns: []*schema.Column{TaxAssociationsColumns[1], TaxAssociationsColumns[7], TaxAssociationsColumns[9], TaxAssociationsColumns[10], TaxAssociationsColumns[2]}, }, { Name: "idx_tax_rate_id_tenant_id_environment_id", Unique: false, Columns: []*schema.Column{TaxAssociationsColumns[1], TaxAssociationsColumns[7], TaxAssociationsColumns[8]}, }, { Name: "unique_entity_tax_mapping", Unique: true, Columns: []*schema.Column{TaxAssociationsColumns[1], TaxAssociationsColumns[7], TaxAssociationsColumns[9], TaxAssociationsColumns[10], TaxAssociationsColumns[8]}, }, }, } // TaxRatesColumns holds the columns for the "tax_rates" table. TaxRatesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "code", Type: field.TypeString}, {Name: "tax_rate_status", Type: field.TypeString}, {Name: "tax_rate_type", Type: field.TypeString, Default: "percentage"}, {Name: "scope", Type: field.TypeString}, {Name: "percentage_value", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(9,6)"}}, {Name: "fixed_value", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(9,6)"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // TaxRatesTable holds the schema information for the "tax_rates" table. TaxRatesTable = &schema.Table{ Name: "tax_rates", Columns: TaxRatesColumns, PrimaryKey: []*schema.Column{TaxRatesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_code_tenant_id_environment_id", Unique: true, Columns: []*schema.Column{TaxRatesColumns[1], TaxRatesColumns[7], TaxRatesColumns[10]}, Annotation: &entsql.IndexAnnotation{ Where: "(code IS NOT NULL AND code != '' and status = 'published')", }, }, }, } // TenantsColumns holds the columns for the "tenants" table. TenantsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(100)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "billing_details", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, } // TenantsTable holds the schema information for the "tenants" table. TenantsTable = &schema.Table{ Name: "tenants", Columns: TenantsColumns, PrimaryKey: []*schema.Column{TenantsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tenant_created_at", Unique: false, Columns: []*schema.Column{TenantsColumns[3]}, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "email", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(255)"}}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_user_email_unique", Unique: true, Columns: []*schema.Column{UsersColumns[7]}, Annotation: &entsql.IndexAnnotation{ Where: "status = 'published'", }, }, { Name: "idx_user_tenant_status", Unique: false, Columns: []*schema.Column{UsersColumns[1], UsersColumns[2]}, }, { Name: "idx_user_tenant_created_at", Unique: false, Columns: []*schema.Column{UsersColumns[1], UsersColumns[3]}, }, }, } // WalletsColumns holds the columns for the "wallets" table. WalletsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "name", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(255)"}}, {Name: "customer_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(10)"}}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "balance", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "credit_balance", Type: field.TypeOther, Default: "0", SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "wallet_status", Type: field.TypeString, Default: "active", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "auto_topup_trigger", Type: field.TypeString, Nullable: true, Default: "disabled", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "auto_topup_min_balance", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "auto_topup_amount", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "wallet_type", Type: field.TypeString, Default: "PRE_PAID", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "conversion_rate", Type: field.TypeOther, Default: "1", SchemaType: map[string]string{"postgres": "numeric(10,5)"}}, {Name: "config", Type: field.TypeJSON, Nullable: true}, {Name: "alert_config", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "alert_enabled", Type: field.TypeBool, Nullable: true, Default: true}, {Name: "alert_state", Type: field.TypeString, Nullable: true, Default: "ok", SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // WalletsTable holds the schema information for the "wallets" table. WalletsTable = &schema.Table{ Name: "wallets", Columns: WalletsColumns, PrimaryKey: []*schema.Column{WalletsColumns[0]}, Indexes: []*schema.Index{ { Name: "wallet_tenant_id_environment_id_customer_id_status", Unique: false, Columns: []*schema.Column{WalletsColumns[1], WalletsColumns[7], WalletsColumns[9], WalletsColumns[2]}, }, { Name: "wallet_tenant_id_environment_id_status_wallet_status", Unique: false, Columns: []*schema.Column{WalletsColumns[1], WalletsColumns[7], WalletsColumns[2], WalletsColumns[15]}, }, }, } // WalletTransactionsColumns holds the columns for the "wallet_transactions" table. WalletTransactionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "tenant_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "status", Type: field.TypeString, Default: "published", SchemaType: map[string]string{"postgres": "varchar(20)"}}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString, Nullable: true}, {Name: "updated_by", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, Default: "", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "wallet_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "type", Type: field.TypeString, Default: "credit"}, {Name: "amount", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "credit_amount", Type: field.TypeOther, Default: "0", SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "credit_balance_before", Type: field.TypeOther, Default: "0", SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "credit_balance_after", Type: field.TypeOther, Default: "0", SchemaType: map[string]string{"postgres": "numeric(20,9)"}}, {Name: "reference_type", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "reference_id", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "transaction_status", Type: field.TypeString, Default: "pending", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "expiry_date", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamp"}}, {Name: "credits_available", Type: field.TypeOther, Default: "0", SchemaType: map[string]string{"postgres": "numeric(20,8)"}}, {Name: "idempotency_key", Type: field.TypeString, Nullable: true}, {Name: "transaction_reason", Type: field.TypeString, Default: "FREE_CREDIT_GRANT", SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "priority", Type: field.TypeInt, Nullable: true}, } // WalletTransactionsTable holds the schema information for the "wallet_transactions" table. WalletTransactionsTable = &schema.Table{ Name: "wallet_transactions", Columns: WalletTransactionsColumns, PrimaryKey: []*schema.Column{WalletTransactionsColumns[0]}, Indexes: []*schema.Index{ { Name: "wallettransaction_tenant_id_environment_id_wallet_id", Unique: false, Columns: []*schema.Column{WalletTransactionsColumns[1], WalletTransactionsColumns[7], WalletTransactionsColumns[8]}, }, { Name: "wallettransaction_tenant_id_environment_id_reference_type_reference_id_status", Unique: false, Columns: []*schema.Column{WalletTransactionsColumns[1], WalletTransactionsColumns[7], WalletTransactionsColumns[14], WalletTransactionsColumns[15], WalletTransactionsColumns[2]}, }, { Name: "wallettransaction_tenant_id_environment_id_created_at", Unique: false, Columns: []*schema.Column{WalletTransactionsColumns[1], WalletTransactionsColumns[7], WalletTransactionsColumns[3]}, }, { Name: "idx_tenant_wallet_type_credits_available_expiry_date", Unique: false, Columns: []*schema.Column{WalletTransactionsColumns[1], WalletTransactionsColumns[7], WalletTransactionsColumns[8], WalletTransactionsColumns[9], WalletTransactionsColumns[20], WalletTransactionsColumns[19]}, Annotation: &entsql.IndexAnnotation{ Where: "credits_available > 0 AND type = 'credit'", }, }, { Name: "idx_tenant_environment_idempotency_key", Unique: true, Columns: []*schema.Column{WalletTransactionsColumns[1], WalletTransactionsColumns[7], WalletTransactionsColumns[21]}, Annotation: &entsql.IndexAnnotation{ Where: "idempotency_key IS NOT NULL AND idempotency_key <> '' AND status='published'", }, }, }, } // CouponAssociationCouponApplicationsColumns holds the columns for the "coupon_association_coupon_applications" table. CouponAssociationCouponApplicationsColumns = []*schema.Column{ {Name: "coupon_association_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, {Name: "coupon_application_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}}, } // CouponAssociationCouponApplicationsTable holds the schema information for the "coupon_association_coupon_applications" table. CouponAssociationCouponApplicationsTable = &schema.Table{ Name: "coupon_association_coupon_applications", Columns: CouponAssociationCouponApplicationsColumns, PrimaryKey: []*schema.Column{CouponAssociationCouponApplicationsColumns[0], CouponAssociationCouponApplicationsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "coupon_association_coupon_applications_coupon_association_id", Columns: []*schema.Column{CouponAssociationCouponApplicationsColumns[0]}, RefColumns: []*schema.Column{CouponAssociationsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "coupon_association_coupon_applications_coupon_application_id", Columns: []*schema.Column{CouponAssociationCouponApplicationsColumns[1]}, RefColumns: []*schema.Column{CouponApplicationsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AddonsTable, AddonAssociationsTable, AlertLogsTable, AuthsTable, BillingSequencesTable, ConnectionsTable, CostsheetTable, CouponsTable, CouponApplicationsTable, CouponAssociationsTable, CreditGrantsTable, CreditGrantApplicationsTable, CreditNotesTable, CreditNoteLineItemsTable, CustomersTable, EntitlementsTable, EntityIntegrationMappingsTable, EnvironmentsTable, FeaturesTable, InvoicesTable, InvoiceLineItemsTable, InvoiceSequencesTable, MetersTable, PaymentsTable, PaymentAttemptsTable, PlansTable, PricesTable, PriceUnitTable, ScheduledTasksTable, SecretsTable, SettingsTable, SubscriptionsTable, SubscriptionLineItemsTable, SubscriptionPausesTable, SubscriptionSchedulesTable, SubscriptionSchedulePhasesTable, TasksTable, TaxAppliedsTable, TaxAssociationsTable, TaxRatesTable, TenantsTable, UsersTable, WalletsTable, WalletTransactionsTable, CouponAssociationCouponApplicationsTable, } )
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.