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 ( // GridsColumns holds the columns for the "grids" table. GridsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "guid", Type: field.TypeString, Size: 50}, {Name: "account", Type: field.TypeString, Size: 50}, {Name: "token", Type: field.TypeString, Size: 50}, {Name: "symbol", Type: field.TypeString, Size: 32}, {Name: "strategy_id", Type: field.TypeString, Size: 50}, {Name: "grid_number", Type: field.TypeInt}, {Name: "order_price", Type: field.TypeString}, {Name: "final_price", Type: field.TypeString}, {Name: "amount", Type: field.TypeString}, {Name: "quantity", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"buying", "selling", "bought"}}, } // GridsTable holds the schema information for the "grids" table. GridsTable = &schema.Table{ Name: "grids", Columns: GridsColumns, PrimaryKey: []*schema.Column{GridsColumns[0]}, Indexes: []*schema.Index{ { Name: "grid_guid", Unique: true, Columns: []*schema.Column{GridsColumns[3]}, }, { Name: "grid_strategy_id", Unique: false, Columns: []*schema.Column{GridsColumns[7]}, }, }, } // NoncesColumns holds the columns for the "nonces" table. NoncesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "account", Type: field.TypeString, Unique: true, Size: 42}, {Name: "nonce", Type: field.TypeUint64}, } // NoncesTable holds the schema information for the "nonces" table. NoncesTable = &schema.Table{ Name: "nonces", Columns: NoncesColumns, PrimaryKey: []*schema.Column{NoncesColumns[0]}, } // OrdersColumns holds the columns for the "orders" table. OrdersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "account", Type: field.TypeString, Size: 50}, {Name: "token", Type: field.TypeString, Size: 50}, {Name: "symbol", Type: field.TypeString, Size: 32}, {Name: "grid_id", Type: field.TypeString, Nullable: true, Size: 50}, {Name: "grid_number", Type: field.TypeInt, Nullable: true}, {Name: "grid_buy_cost", Type: field.TypeString, Nullable: true}, {Name: "strategy_id", Type: field.TypeString, Size: 50}, {Name: "type", Type: field.TypeEnum, Enums: []string{"buy", "sell"}}, {Name: "price", Type: field.TypeString}, {Name: "final_price", Type: field.TypeString}, {Name: "in_amount", Type: field.TypeString}, {Name: "out_amount", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "closed", "rejected"}}, {Name: "nonce", Type: field.TypeUint64}, {Name: "tx_hash", Type: field.TypeString, Size: 100}, {Name: "reason", Type: field.TypeString, Size: 500}, {Name: "profit", Type: field.TypeString, Nullable: true}, } // OrdersTable holds the schema information for the "orders" table. OrdersTable = &schema.Table{ Name: "orders", Columns: OrdersColumns, PrimaryKey: []*schema.Column{OrdersColumns[0]}, Indexes: []*schema.Index{ { Name: "order_strategy_id", Unique: false, Columns: []*schema.Column{OrdersColumns[9]}, }, { Name: "order_tx_hash", Unique: false, Columns: []*schema.Column{OrdersColumns[17]}, }, { Name: "order_account", Unique: false, Columns: []*schema.Column{OrdersColumns[3]}, }, }, } // SettingsColumns holds the columns for the "settings" table. SettingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "user_id", Type: field.TypeInt64}, {Name: "slippage_bps", Type: field.TypeInt}, {Name: "sell_slippage_bps", Type: field.TypeInt, Nullable: true}, {Name: "exit_slippage_bps", Type: field.TypeInt, Nullable: true}, {Name: "dex_aggregator", Type: field.TypeEnum, Enums: []string{"relay"}}, {Name: "enable_infinite_approval", Type: field.TypeBool, Nullable: true}, } // SettingsTable holds the schema information for the "settings" table. SettingsTable = &schema.Table{ Name: "settings", Columns: SettingsColumns, PrimaryKey: []*schema.Column{SettingsColumns[0]}, Indexes: []*schema.Index{ { Name: "settings_user_id", Unique: true, Columns: []*schema.Column{SettingsColumns[3]}, }, }, } // StrategiesColumns holds the columns for the "strategies" table. StrategiesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "guid", Type: field.TypeString, Size: 50}, {Name: "user_id", Type: field.TypeInt64}, {Name: "token", Type: field.TypeString, Size: 50}, {Name: "symbol", Type: field.TypeString, Size: 32}, {Name: "martin_factor", Type: field.TypeFloat64}, {Name: "max_grid_limit", Type: field.TypeInt, Nullable: true}, {Name: "take_profit_ratio", Type: field.TypeString}, {Name: "upper_price_bound", Type: field.TypeString}, {Name: "lower_price_bound", Type: field.TypeString}, {Name: "initial_order_size", Type: field.TypeString}, {Name: "last_kline_volume", Type: field.TypeString, Nullable: true}, {Name: "five_kline_volume", Type: field.TypeString, Nullable: true}, {Name: "first_order_id", Type: field.TypeInt, Nullable: true}, {Name: "upper_bound_exit", Type: field.TypeString, Nullable: true}, {Name: "stop_loss_exit", Type: field.TypeString, Nullable: true}, {Name: "take_profit_exit", Type: field.TypeString, Nullable: true}, {Name: "global_take_profit_ratio", Type: field.TypeString, Nullable: true}, {Name: "dynamic_stop_loss", Type: field.TypeBool, Nullable: true}, {Name: "drop_on", Type: field.TypeBool, Nullable: true}, {Name: "candles_to_check", Type: field.TypeInt, Nullable: true, Default: 0}, {Name: "drop_threshold", Type: field.TypeString, Nullable: true}, {Name: "enable_auto_buy", Type: field.TypeBool}, {Name: "enable_auto_sell", Type: field.TypeBool}, {Name: "enable_auto_exit", Type: field.TypeBool}, {Name: "enable_push_notification", Type: field.TypeBool}, {Name: "status", Type: field.TypeEnum, Enums: []string{"active", "inactive"}}, {Name: "grid_trend", Type: field.TypeString, Nullable: true}, {Name: "last_lower_threshold_alert_time", Type: field.TypeTime, Nullable: true}, {Name: "last_upper_threshold_alert_time", Type: field.TypeTime, Nullable: true}, } // StrategiesTable holds the schema information for the "strategies" table. StrategiesTable = &schema.Table{ Name: "strategies", Columns: StrategiesColumns, PrimaryKey: []*schema.Column{StrategiesColumns[0]}, Indexes: []*schema.Index{ { Name: "strategy_guid", Unique: true, Columns: []*schema.Column{StrategiesColumns[3]}, }, { Name: "strategy_user_id", Unique: false, Columns: []*schema.Column{StrategiesColumns[4]}, }, { Name: "strategy_user_id_token", Unique: true, Columns: []*schema.Column{StrategiesColumns[4], StrategiesColumns[5]}, }, }, } // WalletsColumns holds the columns for the "wallets" table. WalletsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "user_id", Type: field.TypeInt64}, {Name: "account", Type: field.TypeString, Size: 50}, {Name: "password", Type: field.TypeString, Size: 100}, {Name: "private_key", Type: field.TypeString, Size: 200}, } // 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_user_id", Unique: true, Columns: []*schema.Column{WalletsColumns[3]}, }, { Name: "wallet_account", Unique: true, Columns: []*schema.Column{WalletsColumns[4]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ GridsTable, NoncesTable, OrdersTable, SettingsTable, StrategiesTable, WalletsTable, } )
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
Click to show internal directories.
Click to hide internal directories.