migrate

package
v1.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

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 (
	// 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]},
			},
		},
	}
	// 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'",
				},
			},
		},
	}
	// 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: "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)"}},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
	}
	// 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[8]},
				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]},
			},
		},
	}
	// 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: "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: "plan_id", Type: field.TypeString, 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_plans_entitlements",
				Columns:    []*schema.Column{EntitlementsColumns[15]},
				RefColumns: []*schema.Column{PlansColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "entitlement_tenant_id_environment_id_plan_id_feature_id",
				Unique:  true,
				Columns: []*schema.Column{EntitlementsColumns[1], EntitlementsColumns[7], EntitlementsColumns[15], EntitlementsColumns[8]},
				Annotation: &entsql.IndexAnnotation{
					Where: "status = 'published'",
				},
			},
			{
				Name:    "entitlement_tenant_id_environment_id_plan_id",
				Unique:  false,
				Columns: []*schema.Column{EntitlementsColumns[1], EntitlementsColumns[7], EntitlementsColumns[15]},
			},
			{
				Name:    "entitlement_tenant_id_environment_id_feature_id",
				Unique:  false,
				Columns: []*schema.Column{EntitlementsColumns[1], EntitlementsColumns[7], EntitlementsColumns[8]},
			},
		},
	}
	// 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)"}},
	}
	// 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", 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[22], InvoicesColumns[11], InvoicesColumns[12], InvoicesColumns[2]},
			},
			{
				Name:    "idx_tenant_environment_invoice_number_unique",
				Unique:  true,
				Columns: []*schema.Column{InvoicesColumns[1], InvoicesColumns[7], InvoicesColumns[33]},
				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[35]},
				Annotation: &entsql.IndexAnnotation{
					Where: "idempotency_key IS NOT NULL",
				},
			},
			{
				Name:    "idx_subscription_period_unique",
				Unique:  false,
				Columns: []*schema.Column{InvoicesColumns[9], InvoicesColumns[27], InvoicesColumns[28]},
				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: "plan_id", 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: "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[23]},
				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[23], 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[12], InvoiceLineItemsColumns[2]},
			},
			{
				Name:    "invoicelineitem_tenant_id_environment_id_meter_id_status",
				Unique:  false,
				Columns: []*schema.Column{InvoiceLineItemsColumns[1], InvoiceLineItemsColumns[7], InvoiceLineItemsColumns[14], InvoiceLineItemsColumns[2]},
			},
			{
				Name:    "invoicelineitem_period_start_period_end",
				Unique:  false,
				Columns: []*schema.Column{InvoiceLineItemsColumns[20], InvoiceLineItemsColumns[21]},
			},
		},
	}
	// 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: "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_year_month",
				Unique:  true,
				Columns: []*schema.Column{InvoiceSequencesColumns[1], InvoiceSequencesColumns[2]},
			},
		},
	}
	// 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: "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[17], PaymentsColumns[2]},
			},
			{
				Name:    "idx_tenant_payment_method_status",
				Unique:  false,
				Columns: []*schema.Column{PaymentsColumns[1], PaymentsColumns[7], PaymentsColumns[11], PaymentsColumns[12], PaymentsColumns[17], 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: "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},
	}
	// 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[8]},
				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: "plan_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(50)"}},
		{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: "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},
	}
	// PricesTable holds the schema information for the "prices" table.
	PricesTable = &schema.Table{
		Name:       "prices",
		Columns:    PricesColumns,
		PrimaryKey: []*schema.Column{PricesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "price_tenant_id_environment_id_lookup_key",
				Unique:  true,
				Columns: []*schema.Column{PricesColumns[1], PricesColumns[7], PricesColumns[24]},
				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]},
			},
		},
	}
	// 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]},
			},
		},
	}
	// 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)"}},
	}
	// 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]},
			},
		},
	}
	// 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: "plan_id", 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, 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: "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[24]},
				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[24], 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_plan_id_status",
				Unique:  false,
				Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[9], SubscriptionLineItemsColumns[2]},
			},
			{
				Name:    "subscriptionlineitem_tenant_id_environment_id_price_id_status",
				Unique:  false,
				Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[11], SubscriptionLineItemsColumns[2]},
			},
			{
				Name:    "subscriptionlineitem_tenant_id_environment_id_meter_id_status",
				Unique:  false,
				Columns: []*schema.Column{SubscriptionLineItemsColumns[1], SubscriptionLineItemsColumns[7], SubscriptionLineItemsColumns[13], SubscriptionLineItemsColumns[2]},
			},
			{
				Name:    "subscriptionlineitem_start_date_end_date",
				Unique:  false,
				Columns: []*schema.Column{SubscriptionLineItemsColumns[21], SubscriptionLineItemsColumns[22]},
			},
		},
	}
	// 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: "file_url", Type: field.TypeString, 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[13], TasksColumns[2]},
			},
		},
	}
	// 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},
	}
	// 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'",
				},
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		AuthsTable,
		BillingSequencesTable,
		CostsheetTable,
		CreditGrantsTable,
		CreditGrantApplicationsTable,
		CreditNotesTable,
		CreditNoteLineItemsTable,
		CustomersTable,
		EntitlementsTable,
		EnvironmentsTable,
		FeaturesTable,
		InvoicesTable,
		InvoiceLineItemsTable,
		InvoiceSequencesTable,
		MetersTable,
		PaymentsTable,
		PaymentAttemptsTable,
		PlansTable,
		PricesTable,
		SecretsTable,
		SubscriptionsTable,
		SubscriptionLineItemsTable,
		SubscriptionPausesTable,
		SubscriptionSchedulesTable,
		SubscriptionSchedulePhasesTable,
		TasksTable,
		TenantsTable,
		UsersTable,
		WalletsTable,
		WalletTransactionsTable,
	}
)

Functions

func Create

func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error

Create creates all table resources using the given schema driver.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is the API for creating, migrating and dropping a schema.

func NewSchema

func NewSchema(drv dialect.Driver) *Schema

NewSchema creates a new schema client.

func (*Schema) Create

func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error

Create creates all schema resources.

func (*Schema) WriteTo

func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error

WriteTo writes the schema changes to w instead of running them against the database.

if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
	log.Fatal(err)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL