Documentation
¶
Index ¶
- Variables
- func Create(ctx context.Context, s *Schema, tables []*schema.Table, ...) error
- func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error
- func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error
- type Schema
- func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error
- func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error
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 ( // APIKeysColumns holds the columns for the "api_keys" table. APIKeysColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "secret", Type: field.TypeString, Unique: true}, {Name: "provider_profile_api_key", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "sender_profile_api_key", Type: field.TypeUUID, Unique: true, Nullable: true}, } // APIKeysTable holds the schema information for the "api_keys" table. APIKeysTable = &schema.Table{ Name: "api_keys", Columns: APIKeysColumns, PrimaryKey: []*schema.Column{APIKeysColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "api_keys_provider_profiles_api_key", Columns: []*schema.Column{APIKeysColumns[2]}, RefColumns: []*schema.Column{ProviderProfilesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "api_keys_sender_profiles_api_key", Columns: []*schema.Column{APIKeysColumns[3]}, RefColumns: []*schema.Column{SenderProfilesColumns[0]}, OnDelete: schema.Cascade, }, }, } // FiatCurrenciesColumns holds the columns for the "fiat_currencies" table. FiatCurrenciesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "code", Type: field.TypeString, Unique: true}, {Name: "short_name", Type: field.TypeString, Unique: true}, {Name: "decimals", Type: field.TypeInt, Default: 2}, {Name: "symbol", Type: field.TypeString}, {Name: "name", Type: field.TypeString}, {Name: "market_rate", Type: field.TypeFloat64}, {Name: "is_enabled", Type: field.TypeBool, Default: false}, } // FiatCurrenciesTable holds the schema information for the "fiat_currencies" table. FiatCurrenciesTable = &schema.Table{ Name: "fiat_currencies", Columns: FiatCurrenciesColumns, PrimaryKey: []*schema.Column{FiatCurrenciesColumns[0]}, } // IdentityVerificationRequestsColumns holds the columns for the "identity_verification_requests" table. IdentityVerificationRequestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "wallet_address", Type: field.TypeString, Unique: true}, {Name: "wallet_signature", Type: field.TypeString, Unique: true}, {Name: "platform", Type: field.TypeEnum, Enums: []string{"smile_id", "metamap", "sumsub", "synaps"}}, {Name: "platform_ref", Type: field.TypeString}, {Name: "verification_url", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "success", "failed"}, Default: "pending"}, {Name: "fee_reclaimed", Type: field.TypeBool, Default: false}, {Name: "updated_at", Type: field.TypeTime}, {Name: "last_url_created_at", Type: field.TypeTime}, } // IdentityVerificationRequestsTable holds the schema information for the "identity_verification_requests" table. IdentityVerificationRequestsTable = &schema.Table{ Name: "identity_verification_requests", Columns: IdentityVerificationRequestsColumns, PrimaryKey: []*schema.Column{IdentityVerificationRequestsColumns[0]}, } // InstitutionsColumns holds the columns for the "institutions" table. InstitutionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "code", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "type", Type: field.TypeEnum, Enums: []string{"bank", "mobile_money"}, Default: "bank"}, {Name: "fiat_currency_institutions", Type: field.TypeUUID, Nullable: true}, } // InstitutionsTable holds the schema information for the "institutions" table. InstitutionsTable = &schema.Table{ Name: "institutions", Columns: InstitutionsColumns, PrimaryKey: []*schema.Column{InstitutionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "institutions_fiat_currencies_institutions", Columns: []*schema.Column{InstitutionsColumns[6]}, RefColumns: []*schema.Column{FiatCurrenciesColumns[0]}, OnDelete: schema.SetNull, }, }, } // LinkedAddressesColumns holds the columns for the "linked_addresses" table. LinkedAddressesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "address", Type: field.TypeString, Unique: true}, {Name: "salt", Type: field.TypeBytes, Unique: true}, {Name: "institution", Type: field.TypeString}, {Name: "account_identifier", Type: field.TypeString}, {Name: "account_name", Type: field.TypeString}, {Name: "owner_address", Type: field.TypeString, Unique: true}, {Name: "last_indexed_block", Type: field.TypeInt64, Nullable: true}, {Name: "tx_hash", Type: field.TypeString, Nullable: true, Size: 70}, {Name: "sender_profile_linked_address", Type: field.TypeUUID, Nullable: true}, } // LinkedAddressesTable holds the schema information for the "linked_addresses" table. LinkedAddressesTable = &schema.Table{ Name: "linked_addresses", Columns: LinkedAddressesColumns, PrimaryKey: []*schema.Column{LinkedAddressesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "linked_addresses_sender_profiles_linked_address", Columns: []*schema.Column{LinkedAddressesColumns[11]}, RefColumns: []*schema.Column{SenderProfilesColumns[0]}, OnDelete: schema.Cascade, }, }, } // LockOrderFulfillmentsColumns holds the columns for the "lock_order_fulfillments" table. LockOrderFulfillmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "tx_id", Type: field.TypeString, Nullable: true}, {Name: "psp", Type: field.TypeString, Nullable: true}, {Name: "validation_status", Type: field.TypeEnum, Enums: []string{"pending", "success", "failed"}, Default: "pending"}, {Name: "validation_error", Type: field.TypeString, Nullable: true}, {Name: "lock_payment_order_fulfillments", Type: field.TypeUUID}, } // LockOrderFulfillmentsTable holds the schema information for the "lock_order_fulfillments" table. LockOrderFulfillmentsTable = &schema.Table{ Name: "lock_order_fulfillments", Columns: LockOrderFulfillmentsColumns, PrimaryKey: []*schema.Column{LockOrderFulfillmentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "lock_order_fulfillments_lock_payment_orders_fulfillments", Columns: []*schema.Column{LockOrderFulfillmentsColumns[7]}, RefColumns: []*schema.Column{LockPaymentOrdersColumns[0]}, OnDelete: schema.Cascade, }, }, } // LockPaymentOrdersColumns holds the columns for the "lock_payment_orders" table. LockPaymentOrdersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "gateway_id", Type: field.TypeString}, {Name: "amount", Type: field.TypeFloat64}, {Name: "rate", Type: field.TypeFloat64}, {Name: "order_percent", Type: field.TypeFloat64}, {Name: "tx_hash", Type: field.TypeString, Nullable: true, Size: 70}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "processing", "cancelled", "fulfilled", "validated", "settled", "refunded"}, Default: "pending"}, {Name: "block_number", Type: field.TypeInt64}, {Name: "institution", Type: field.TypeString}, {Name: "account_identifier", Type: field.TypeString}, {Name: "account_name", Type: field.TypeString}, {Name: "memo", Type: field.TypeString, Nullable: true}, {Name: "cancellation_count", Type: field.TypeInt, Default: 0}, {Name: "cancellation_reasons", Type: field.TypeJSON}, {Name: "provider_profile_assigned_orders", Type: field.TypeString, Nullable: true}, {Name: "provision_bucket_lock_payment_orders", Type: field.TypeInt, Nullable: true}, {Name: "token_lock_payment_orders", Type: field.TypeInt}, } // LockPaymentOrdersTable holds the schema information for the "lock_payment_orders" table. LockPaymentOrdersTable = &schema.Table{ Name: "lock_payment_orders", Columns: LockPaymentOrdersColumns, PrimaryKey: []*schema.Column{LockPaymentOrdersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "lock_payment_orders_provider_profiles_assigned_orders", Columns: []*schema.Column{LockPaymentOrdersColumns[16]}, RefColumns: []*schema.Column{ProviderProfilesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "lock_payment_orders_provision_buckets_lock_payment_orders", Columns: []*schema.Column{LockPaymentOrdersColumns[17]}, RefColumns: []*schema.Column{ProvisionBucketsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "lock_payment_orders_tokens_lock_payment_orders", Columns: []*schema.Column{LockPaymentOrdersColumns[18]}, RefColumns: []*schema.Column{TokensColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "lockpaymentorder_gateway_id_rate_tx_hash_block_number_institution_account_identifier_account_name_memo_token_lock_payment_orders", Unique: true, Columns: []*schema.Column{LockPaymentOrdersColumns[3], LockPaymentOrdersColumns[5], LockPaymentOrdersColumns[7], LockPaymentOrdersColumns[9], LockPaymentOrdersColumns[10], LockPaymentOrdersColumns[11], LockPaymentOrdersColumns[12], LockPaymentOrdersColumns[13], LockPaymentOrdersColumns[18]}, }, }, } // NetworksColumns holds the columns for the "networks" table. NetworksColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "chain_id", Type: field.TypeInt64}, {Name: "chain_id_hex", Type: field.TypeString, Nullable: true}, {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "rpc_endpoint", Type: field.TypeString}, {Name: "gateway_contract_address", Type: field.TypeString, Default: ""}, {Name: "is_testnet", Type: field.TypeBool}, {Name: "bundler_url", Type: field.TypeString, Nullable: true}, {Name: "paymaster_url", Type: field.TypeString, Nullable: true}, {Name: "fee", Type: field.TypeFloat64}, } // NetworksTable holds the schema information for the "networks" table. NetworksTable = &schema.Table{ Name: "networks", Columns: NetworksColumns, PrimaryKey: []*schema.Column{NetworksColumns[0]}, } // PaymentOrdersColumns holds the columns for the "payment_orders" table. PaymentOrdersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "amount", Type: field.TypeFloat64}, {Name: "amount_paid", Type: field.TypeFloat64}, {Name: "amount_returned", Type: field.TypeFloat64}, {Name: "percent_settled", Type: field.TypeFloat64}, {Name: "sender_fee", Type: field.TypeFloat64}, {Name: "network_fee", Type: field.TypeFloat64}, {Name: "protocol_fee", Type: field.TypeFloat64}, {Name: "rate", Type: field.TypeFloat64}, {Name: "tx_hash", Type: field.TypeString, Nullable: true, Size: 70}, {Name: "block_number", Type: field.TypeInt64, Default: 0}, {Name: "from_address", Type: field.TypeString, Nullable: true, Size: 60}, {Name: "return_address", Type: field.TypeString, Nullable: true, Size: 60}, {Name: "receive_address_text", Type: field.TypeString, Size: 60}, {Name: "fee_percent", Type: field.TypeFloat64}, {Name: "fee_address", Type: field.TypeString, Nullable: true, Size: 60}, {Name: "gateway_id", Type: field.TypeString, Nullable: true, Size: 70}, {Name: "reference", Type: field.TypeString, Nullable: true, Size: 70}, {Name: "status", Type: field.TypeEnum, Enums: []string{"initiated", "pending", "expired", "settled", "refunded"}, Default: "initiated"}, {Name: "api_key_payment_orders", Type: field.TypeUUID, Nullable: true}, {Name: "linked_address_payment_orders", Type: field.TypeInt, Nullable: true}, {Name: "sender_profile_payment_orders", Type: field.TypeUUID, Nullable: true}, {Name: "token_payment_orders", Type: field.TypeInt}, } // PaymentOrdersTable holds the schema information for the "payment_orders" table. PaymentOrdersTable = &schema.Table{ Name: "payment_orders", Columns: PaymentOrdersColumns, PrimaryKey: []*schema.Column{PaymentOrdersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "payment_orders_api_keys_payment_orders", Columns: []*schema.Column{PaymentOrdersColumns[21]}, RefColumns: []*schema.Column{APIKeysColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "payment_orders_linked_addresses_payment_orders", Columns: []*schema.Column{PaymentOrdersColumns[22]}, RefColumns: []*schema.Column{LinkedAddressesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "payment_orders_sender_profiles_payment_orders", Columns: []*schema.Column{PaymentOrdersColumns[23]}, RefColumns: []*schema.Column{SenderProfilesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "payment_orders_tokens_payment_orders", Columns: []*schema.Column{PaymentOrdersColumns[24]}, RefColumns: []*schema.Column{TokensColumns[0]}, OnDelete: schema.Cascade, }, }, } // PaymentOrderRecipientsColumns holds the columns for the "payment_order_recipients" table. PaymentOrderRecipientsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "institution", Type: field.TypeString}, {Name: "account_identifier", Type: field.TypeString}, {Name: "account_name", Type: field.TypeString}, {Name: "memo", Type: field.TypeString, Nullable: true}, {Name: "provider_id", Type: field.TypeString, Nullable: true}, {Name: "payment_order_recipient", Type: field.TypeUUID, Unique: true}, } // PaymentOrderRecipientsTable holds the schema information for the "payment_order_recipients" table. PaymentOrderRecipientsTable = &schema.Table{ Name: "payment_order_recipients", Columns: PaymentOrderRecipientsColumns, PrimaryKey: []*schema.Column{PaymentOrderRecipientsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "payment_order_recipients_payment_orders_recipient", Columns: []*schema.Column{PaymentOrderRecipientsColumns[6]}, RefColumns: []*schema.Column{PaymentOrdersColumns[0]}, OnDelete: schema.Cascade, }, }, } // ProviderOrderTokensColumns holds the columns for the "provider_order_tokens" table. ProviderOrderTokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "fixed_conversion_rate", Type: field.TypeFloat64}, {Name: "floating_conversion_rate", Type: field.TypeFloat64}, {Name: "conversion_rate_type", Type: field.TypeEnum, Enums: []string{"fixed", "floating"}}, {Name: "max_order_amount", Type: field.TypeFloat64}, {Name: "min_order_amount", Type: field.TypeFloat64}, {Name: "address", Type: field.TypeString, Nullable: true}, {Name: "network", Type: field.TypeString, Nullable: true}, {Name: "fiat_currency_provider_order_tokens", Type: field.TypeUUID}, {Name: "provider_profile_order_tokens", Type: field.TypeString}, {Name: "token_provider_order_tokens", Type: field.TypeInt}, } // ProviderOrderTokensTable holds the schema information for the "provider_order_tokens" table. ProviderOrderTokensTable = &schema.Table{ Name: "provider_order_tokens", Columns: ProviderOrderTokensColumns, PrimaryKey: []*schema.Column{ProviderOrderTokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "provider_order_tokens_fiat_currencies_provider_order_tokens", Columns: []*schema.Column{ProviderOrderTokensColumns[10]}, RefColumns: []*schema.Column{FiatCurrenciesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "provider_order_tokens_provider_profiles_order_tokens", Columns: []*schema.Column{ProviderOrderTokensColumns[11]}, RefColumns: []*schema.Column{ProviderProfilesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "provider_order_tokens_tokens_provider_order_tokens", Columns: []*schema.Column{ProviderOrderTokensColumns[12]}, RefColumns: []*schema.Column{TokensColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "providerordertoken_provider_profile_order_tokens_token_provider_order_tokens_fiat_currency_provider_order_tokens", Unique: true, Columns: []*schema.Column{ProviderOrderTokensColumns[11], ProviderOrderTokensColumns[12], ProviderOrderTokensColumns[10]}, }, }, } // ProviderProfilesColumns holds the columns for the "provider_profiles" table. ProviderProfilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "trading_name", Type: field.TypeString, Nullable: true, Size: 80}, {Name: "host_identifier", Type: field.TypeString, Nullable: true}, {Name: "provision_mode", Type: field.TypeEnum, Enums: []string{"manual", "auto"}, Default: "auto"}, {Name: "is_active", Type: field.TypeBool, Default: false}, {Name: "is_available", Type: field.TypeBool, Default: false}, {Name: "updated_at", Type: field.TypeTime}, {Name: "visibility_mode", Type: field.TypeEnum, Enums: []string{"private", "public"}, Default: "public"}, {Name: "address", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "mobile_number", Type: field.TypeString, Nullable: true}, {Name: "date_of_birth", Type: field.TypeTime, Nullable: true}, {Name: "business_name", Type: field.TypeString, Nullable: true}, {Name: "identity_document_type", Type: field.TypeEnum, Nullable: true, Enums: []string{"passport", "drivers_license", "national_id"}}, {Name: "identity_document", Type: field.TypeString, Nullable: true}, {Name: "business_document", Type: field.TypeString, Nullable: true}, {Name: "is_kyb_verified", Type: field.TypeBool, Default: false}, {Name: "user_provider_profile", Type: field.TypeUUID, Unique: true}, } // ProviderProfilesTable holds the schema information for the "provider_profiles" table. ProviderProfilesTable = &schema.Table{ Name: "provider_profiles", Columns: ProviderProfilesColumns, PrimaryKey: []*schema.Column{ProviderProfilesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "provider_profiles_users_provider_profile", Columns: []*schema.Column{ProviderProfilesColumns[16]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // ProviderRatingsColumns holds the columns for the "provider_ratings" table. ProviderRatingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "trust_score", Type: field.TypeFloat64}, {Name: "provider_profile_provider_rating", Type: field.TypeString, Unique: true}, } // ProviderRatingsTable holds the schema information for the "provider_ratings" table. ProviderRatingsTable = &schema.Table{ Name: "provider_ratings", Columns: ProviderRatingsColumns, PrimaryKey: []*schema.Column{ProviderRatingsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "provider_ratings_provider_profiles_provider_rating", Columns: []*schema.Column{ProviderRatingsColumns[4]}, RefColumns: []*schema.Column{ProviderProfilesColumns[0]}, OnDelete: schema.NoAction, }, }, } // ProvisionBucketsColumns holds the columns for the "provision_buckets" table. ProvisionBucketsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "min_amount", Type: field.TypeFloat64}, {Name: "max_amount", Type: field.TypeFloat64}, {Name: "created_at", Type: field.TypeTime}, {Name: "fiat_currency_provision_buckets", Type: field.TypeUUID}, } // ProvisionBucketsTable holds the schema information for the "provision_buckets" table. ProvisionBucketsTable = &schema.Table{ Name: "provision_buckets", Columns: ProvisionBucketsColumns, PrimaryKey: []*schema.Column{ProvisionBucketsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "provision_buckets_fiat_currencies_provision_buckets", Columns: []*schema.Column{ProvisionBucketsColumns[4]}, RefColumns: []*schema.Column{FiatCurrenciesColumns[0]}, OnDelete: schema.Cascade, }, }, } // ReceiveAddressesColumns holds the columns for the "receive_addresses" table. ReceiveAddressesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "address", Type: field.TypeString, Unique: true}, {Name: "salt", Type: field.TypeBytes, Unique: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"unused", "used", "expired"}, Default: "unused"}, {Name: "last_indexed_block", Type: field.TypeInt64, Nullable: true}, {Name: "last_used", Type: field.TypeTime, Nullable: true}, {Name: "tx_hash", Type: field.TypeString, Nullable: true, Size: 70}, {Name: "valid_until", Type: field.TypeTime, Nullable: true}, {Name: "payment_order_receive_address", Type: field.TypeUUID, Unique: true, Nullable: true}, } // ReceiveAddressesTable holds the schema information for the "receive_addresses" table. ReceiveAddressesTable = &schema.Table{ Name: "receive_addresses", Columns: ReceiveAddressesColumns, PrimaryKey: []*schema.Column{ReceiveAddressesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "receive_addresses_payment_orders_receive_address", Columns: []*schema.Column{ReceiveAddressesColumns[10]}, RefColumns: []*schema.Column{PaymentOrdersColumns[0]}, OnDelete: schema.SetNull, }, }, } // SenderOrderTokensColumns holds the columns for the "sender_order_tokens" table. SenderOrderTokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "fee_percent", Type: field.TypeFloat64}, {Name: "fee_address", Type: field.TypeString, Size: 60}, {Name: "refund_address", Type: field.TypeString, Size: 60}, {Name: "sender_profile_order_tokens", Type: field.TypeUUID}, {Name: "token_sender_order_tokens", Type: field.TypeInt}, } // SenderOrderTokensTable holds the schema information for the "sender_order_tokens" table. SenderOrderTokensTable = &schema.Table{ Name: "sender_order_tokens", Columns: SenderOrderTokensColumns, PrimaryKey: []*schema.Column{SenderOrderTokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "sender_order_tokens_sender_profiles_order_tokens", Columns: []*schema.Column{SenderOrderTokensColumns[6]}, RefColumns: []*schema.Column{SenderProfilesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "sender_order_tokens_tokens_sender_order_tokens", Columns: []*schema.Column{SenderOrderTokensColumns[7]}, RefColumns: []*schema.Column{TokensColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "senderordertoken_sender_profile_order_tokens_token_sender_order_tokens", Unique: true, Columns: []*schema.Column{SenderOrderTokensColumns[6], SenderOrderTokensColumns[7]}, }, }, } // SenderProfilesColumns holds the columns for the "sender_profiles" table. SenderProfilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "webhook_url", Type: field.TypeString, Nullable: true}, {Name: "domain_whitelist", Type: field.TypeJSON}, {Name: "provider_id", Type: field.TypeString, Nullable: true}, {Name: "is_partner", Type: field.TypeBool, Default: false}, {Name: "is_active", Type: field.TypeBool, Default: false}, {Name: "updated_at", Type: field.TypeTime}, {Name: "user_sender_profile", Type: field.TypeUUID, Unique: true}, } // SenderProfilesTable holds the schema information for the "sender_profiles" table. SenderProfilesTable = &schema.Table{ Name: "sender_profiles", Columns: SenderProfilesColumns, PrimaryKey: []*schema.Column{SenderProfilesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "sender_profiles_users_sender_profile", Columns: []*schema.Column{SenderProfilesColumns[7]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // TokensColumns holds the columns for the "tokens" table. TokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "symbol", Type: field.TypeString, Size: 10}, {Name: "contract_address", Type: field.TypeString, Size: 60}, {Name: "decimals", Type: field.TypeInt8}, {Name: "is_enabled", Type: field.TypeBool, Default: false}, {Name: "base_currency", Type: field.TypeString, Default: "USD"}, {Name: "network_tokens", Type: field.TypeInt}, } // TokensTable holds the schema information for the "tokens" table. TokensTable = &schema.Table{ Name: "tokens", Columns: TokensColumns, PrimaryKey: []*schema.Column{TokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "tokens_networks_tokens", Columns: []*schema.Column{TokensColumns[8]}, RefColumns: []*schema.Column{NetworksColumns[0]}, OnDelete: schema.Cascade, }, }, } // TransactionLogsColumns holds the columns for the "transaction_logs" table. TransactionLogsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "gateway_id", Type: field.TypeString, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"order_initiated", "crypto_deposited", "order_created", "order_processing", "order_fulfilled", "order_validated", "order_settled", "order_refunded", "gas_prefunded", "gateway_approved"}, Default: "order_initiated"}, {Name: "network", Type: field.TypeString, Nullable: true}, {Name: "tx_hash", Type: field.TypeString, Nullable: true}, {Name: "metadata", Type: field.TypeJSON}, {Name: "created_at", Type: field.TypeTime}, {Name: "lock_payment_order_transactions", Type: field.TypeUUID, Nullable: true}, {Name: "payment_order_transactions", Type: field.TypeUUID, Nullable: true}, } // TransactionLogsTable holds the schema information for the "transaction_logs" table. TransactionLogsTable = &schema.Table{ Name: "transaction_logs", Columns: TransactionLogsColumns, PrimaryKey: []*schema.Column{TransactionLogsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "transaction_logs_lock_payment_orders_transactions", Columns: []*schema.Column{TransactionLogsColumns[7]}, RefColumns: []*schema.Column{LockPaymentOrdersColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "transaction_logs_payment_orders_transactions", Columns: []*schema.Column{TransactionLogsColumns[8]}, RefColumns: []*schema.Column{PaymentOrdersColumns[0]}, OnDelete: schema.SetNull, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "first_name", Type: field.TypeString, Size: 80}, {Name: "last_name", Type: field.TypeString, Size: 80}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "password", Type: field.TypeString}, {Name: "scope", Type: field.TypeString}, {Name: "is_email_verified", Type: field.TypeBool, Default: false}, {Name: "has_early_access", Type: field.TypeBool, Default: false}, } // 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: "user_email_scope", Unique: true, Columns: []*schema.Column{UsersColumns[5], UsersColumns[7]}, }, }, } // VerificationTokensColumns holds the columns for the "verification_tokens" table. VerificationTokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "token", Type: field.TypeString}, {Name: "scope", Type: field.TypeEnum, Enums: []string{"emailVerification", "resetPassword"}}, {Name: "expiry_at", Type: field.TypeTime}, {Name: "user_verification_token", Type: field.TypeUUID}, } // VerificationTokensTable holds the schema information for the "verification_tokens" table. VerificationTokensTable = &schema.Table{ Name: "verification_tokens", Columns: VerificationTokensColumns, PrimaryKey: []*schema.Column{VerificationTokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "verification_tokens_users_verification_token", Columns: []*schema.Column{VerificationTokensColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // WebhookRetryAttemptsColumns holds the columns for the "webhook_retry_attempts" table. WebhookRetryAttemptsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "attempt_number", Type: field.TypeInt}, {Name: "next_retry_time", Type: field.TypeTime}, {Name: "payload", Type: field.TypeJSON}, {Name: "signature", Type: field.TypeString, Nullable: true}, {Name: "webhook_url", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"success", "failed", "expired"}, Default: "failed"}, } // WebhookRetryAttemptsTable holds the schema information for the "webhook_retry_attempts" table. WebhookRetryAttemptsTable = &schema.Table{ Name: "webhook_retry_attempts", Columns: WebhookRetryAttemptsColumns, PrimaryKey: []*schema.Column{WebhookRetryAttemptsColumns[0]}, } // FiatCurrencyProvidersColumns holds the columns for the "fiat_currency_providers" table. FiatCurrencyProvidersColumns = []*schema.Column{ {Name: "fiat_currency_id", Type: field.TypeUUID}, {Name: "provider_profile_id", Type: field.TypeString}, } // FiatCurrencyProvidersTable holds the schema information for the "fiat_currency_providers" table. FiatCurrencyProvidersTable = &schema.Table{ Name: "fiat_currency_providers", Columns: FiatCurrencyProvidersColumns, PrimaryKey: []*schema.Column{FiatCurrencyProvidersColumns[0], FiatCurrencyProvidersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "fiat_currency_providers_fiat_currency_id", Columns: []*schema.Column{FiatCurrencyProvidersColumns[0]}, RefColumns: []*schema.Column{FiatCurrenciesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "fiat_currency_providers_provider_profile_id", Columns: []*schema.Column{FiatCurrencyProvidersColumns[1]}, RefColumns: []*schema.Column{ProviderProfilesColumns[0]}, OnDelete: schema.Cascade, }, }, } // ProvisionBucketProviderProfilesColumns holds the columns for the "provision_bucket_provider_profiles" table. ProvisionBucketProviderProfilesColumns = []*schema.Column{ {Name: "provision_bucket_id", Type: field.TypeInt}, {Name: "provider_profile_id", Type: field.TypeString}, } // ProvisionBucketProviderProfilesTable holds the schema information for the "provision_bucket_provider_profiles" table. ProvisionBucketProviderProfilesTable = &schema.Table{ Name: "provision_bucket_provider_profiles", Columns: ProvisionBucketProviderProfilesColumns, PrimaryKey: []*schema.Column{ProvisionBucketProviderProfilesColumns[0], ProvisionBucketProviderProfilesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "provision_bucket_provider_profiles_provision_bucket_id", Columns: []*schema.Column{ProvisionBucketProviderProfilesColumns[0]}, RefColumns: []*schema.Column{ProvisionBucketsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "provision_bucket_provider_profiles_provider_profile_id", Columns: []*schema.Column{ProvisionBucketProviderProfilesColumns[1]}, RefColumns: []*schema.Column{ProviderProfilesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ APIKeysTable, FiatCurrenciesTable, IdentityVerificationRequestsTable, InstitutionsTable, LinkedAddressesTable, LockOrderFulfillmentsTable, LockPaymentOrdersTable, NetworksTable, PaymentOrdersTable, PaymentOrderRecipientsTable, ProviderOrderTokensTable, ProviderProfilesTable, ProviderRatingsTable, ProvisionBucketsTable, ReceiveAddressesTable, SenderOrderTokensTable, SenderProfilesTable, TokensTable, TransactionLogsTable, UsersTable, VerificationTokensTable, WebhookRetryAttemptsTable, FiatCurrencyProvidersTable, ProvisionBucketProviderProfilesTable, } )
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 (*Schema) Diff ¶
Diff creates a migration file containing the statements to resolve the diff between the Ent schema and the connected database.
func (*Schema) NamedDiff ¶
NamedDiff creates a named migration file containing the statements to resolve the diff between the Ent schema and the connected database.
Click to show internal directories.
Click to hide internal directories.