migrate

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 6 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 (
	// BarGroupsColumns holds the columns for the "bar_groups" table.
	BarGroupsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "first", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "last", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "count", Type: field.TypeInt},
		{Name: "time_range_id", Type: field.TypeInt},
	}
	// BarGroupsTable holds the schema information for the "bar_groups" table.
	BarGroupsTable = &schema.Table{
		Name:       "bar_groups",
		Columns:    BarGroupsColumns,
		PrimaryKey: []*schema.Column{BarGroupsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bar_groups_bar_time_ranges_groups",
				Columns:    []*schema.Column{BarGroupsColumns[4]},
				RefColumns: []*schema.Column{BarTimeRangesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "bargroup_time_range_id_first_last",
				Unique:  true,
				Columns: []*schema.Column{BarGroupsColumns[4], BarGroupsColumns[1], BarGroupsColumns[2]},
			},
		},
	}
	// BarRecordsColumns holds the columns for the "bar_records" table.
	BarRecordsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "close", Type: field.TypeFloat64},
		{Name: "high", Type: field.TypeFloat64},
		{Name: "low", Type: field.TypeFloat64},
		{Name: "open", Type: field.TypeFloat64},
		{Name: "timestamp", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "volume", Type: field.TypeFloat64},
		{Name: "transactions", Type: field.TypeInt32},
		{Name: "bar_group_records", Type: field.TypeInt, Nullable: true},
	}
	// BarRecordsTable holds the schema information for the "bar_records" table.
	BarRecordsTable = &schema.Table{
		Name:       "bar_records",
		Columns:    BarRecordsColumns,
		PrimaryKey: []*schema.Column{BarRecordsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bar_records_bar_groups_records",
				Columns:    []*schema.Column{BarRecordsColumns[8]},
				RefColumns: []*schema.Column{BarGroupsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// BarTimeRangesColumns holds the columns for the "bar_time_ranges" table.
	BarTimeRangesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "start", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "end", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "count", Type: field.TypeInt, Default: 0},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "created", "clean", "consolidated"}, Default: "pending"},
		{Name: "update_time", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP", SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "interval_id", Type: field.TypeInt},
	}
	// BarTimeRangesTable holds the schema information for the "bar_time_ranges" table.
	BarTimeRangesTable = &schema.Table{
		Name:       "bar_time_ranges",
		Columns:    BarTimeRangesColumns,
		PrimaryKey: []*schema.Column{BarTimeRangesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bar_time_ranges_intervals_bars",
				Columns:    []*schema.Column{BarTimeRangesColumns[6]},
				RefColumns: []*schema.Column{IntervalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "bartimerange_interval_id_start_end",
				Unique:  true,
				Columns: []*schema.Column{BarTimeRangesColumns[6], BarTimeRangesColumns[1], BarTimeRangesColumns[2]},
			},
		},
	}
	// DataSourcesColumns holds the columns for the "data_sources" table.
	DataSourcesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString, Unique: true},
		{Name: "address", Type: field.TypeString, Default: ""},
	}
	// DataSourcesTable holds the schema information for the "data_sources" table.
	DataSourcesTable = &schema.Table{
		Name:       "data_sources",
		Columns:    DataSourcesColumns,
		PrimaryKey: []*schema.Column{DataSourcesColumns[0]},
	}
	// DividendsColumns holds the columns for the "dividends" table.
	DividendsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "cash_amount", Type: field.TypeFloat64},
		{Name: "declaration_date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "dividend_type", Type: field.TypeEnum, Enums: []string{"CD", "SC", "LT", "ST"}},
		{Name: "ex_dividend_date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "frequency", Type: field.TypeInt},
		{Name: "record_date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "pay_date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
	}
	// DividendsTable holds the schema information for the "dividends" table.
	DividendsTable = &schema.Table{
		Name:       "dividends",
		Columns:    DividendsColumns,
		PrimaryKey: []*schema.Column{DividendsColumns[0]},
	}
	// EntitiesColumns holds the columns for the "entities" table.
	EntitiesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "active", Type: field.TypeBool},
		{Name: "ticker", Type: field.TypeString},
		{Name: "name", Type: field.TypeString},
		{Name: "description", Type: field.TypeString, Size: 1000},
		{Name: "list_date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "delisted", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
	}
	// EntitiesTable holds the schema information for the "entities" table.
	EntitiesTable = &schema.Table{
		Name:       "entities",
		Columns:    EntitiesColumns,
		PrimaryKey: []*schema.Column{EntitiesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "entity_ticker_list_date",
				Unique:  true,
				Columns: []*schema.Column{EntitiesColumns[2], EntitiesColumns[5]},
			},
		},
	}
	// ExchangesColumns holds the columns for the "exchanges" table.
	ExchangesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "code", Type: field.TypeString},
		{Name: "name", Type: field.TypeString},
		{Name: "trade_record_exchange", Type: field.TypeInt, Nullable: true},
	}
	// ExchangesTable holds the schema information for the "exchanges" table.
	ExchangesTable = &schema.Table{
		Name:       "exchanges",
		Columns:    ExchangesColumns,
		PrimaryKey: []*schema.Column{ExchangesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "exchanges_trade_records_exchange",
				Columns:    []*schema.Column{ExchangesColumns[3]},
				RefColumns: []*schema.Column{TradeRecordsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// FinancialsColumns holds the columns for the "financials" table.
	FinancialsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
	}
	// FinancialsTable holds the schema information for the "financials" table.
	FinancialsTable = &schema.Table{
		Name:       "financials",
		Columns:    FinancialsColumns,
		PrimaryKey: []*schema.Column{FinancialsColumns[0]},
	}
	// IntervalsColumns holds the columns for the "intervals" table.
	IntervalsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "active", Type: field.TypeBool, Default: false},
		{Name: "interval", Type: field.TypeEnum, Enums: []string{"trades", "1min", "daily", "monthly", "yearly"}},
		{Name: "data_source_id", Type: field.TypeInt},
		{Name: "stock_id", Type: field.TypeInt},
	}
	// IntervalsTable holds the schema information for the "intervals" table.
	IntervalsTable = &schema.Table{
		Name:       "intervals",
		Columns:    IntervalsColumns,
		PrimaryKey: []*schema.Column{IntervalsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "intervals_data_sources_intervals",
				Columns:    []*schema.Column{IntervalsColumns[3]},
				RefColumns: []*schema.Column{DataSourcesColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "intervals_entities_intervals",
				Columns:    []*schema.Column{IntervalsColumns[4]},
				RefColumns: []*schema.Column{EntitiesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "interval_stock_id_data_source_id_interval",
				Unique:  true,
				Columns: []*schema.Column{IntervalsColumns[4], IntervalsColumns[3], IntervalsColumns[2]},
			},
		},
	}
	// MarketHoursColumns holds the columns for the "market_hours" table.
	MarketHoursColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "start_time", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "end_time", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "market_info_hours", Type: field.TypeInt, Nullable: true},
	}
	// MarketHoursTable holds the schema information for the "market_hours" table.
	MarketHoursTable = &schema.Table{
		Name:       "market_hours",
		Columns:    MarketHoursColumns,
		PrimaryKey: []*schema.Column{MarketHoursColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "market_hours_market_infos_hours",
				Columns:    []*schema.Column{MarketHoursColumns[4]},
				RefColumns: []*schema.Column{MarketInfosColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// MarketInfosColumns holds the columns for the "market_infos" table.
	MarketInfosColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "hours_start", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "hours_end", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
	}
	// MarketInfosTable holds the schema information for the "market_infos" table.
	MarketInfosTable = &schema.Table{
		Name:       "market_infos",
		Columns:    MarketInfosColumns,
		PrimaryKey: []*schema.Column{MarketInfosColumns[0]},
	}
	// SplitsColumns holds the columns for the "splits" table.
	SplitsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "execution_date", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "from", Type: field.TypeFloat64},
		{Name: "to", Type: field.TypeFloat64},
		{Name: "entity_splits", Type: field.TypeInt, Nullable: true},
	}
	// SplitsTable holds the schema information for the "splits" table.
	SplitsTable = &schema.Table{
		Name:       "splits",
		Columns:    SplitsColumns,
		PrimaryKey: []*schema.Column{SplitsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "splits_entities_splits",
				Columns:    []*schema.Column{SplitsColumns[4]},
				RefColumns: []*schema.Column{EntitiesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// TradeConditionsColumns holds the columns for the "trade_conditions" table.
	TradeConditionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "condition", Type: field.TypeString},
	}
	// TradeConditionsTable holds the schema information for the "trade_conditions" table.
	TradeConditionsTable = &schema.Table{
		Name:       "trade_conditions",
		Columns:    TradeConditionsColumns,
		PrimaryKey: []*schema.Column{TradeConditionsColumns[0]},
	}
	// TradeCorrectionsColumns holds the columns for the "trade_corrections" table.
	TradeCorrectionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "correction", Type: field.TypeString},
	}
	// TradeCorrectionsTable holds the schema information for the "trade_corrections" table.
	TradeCorrectionsTable = &schema.Table{
		Name:       "trade_corrections",
		Columns:    TradeCorrectionsColumns,
		PrimaryKey: []*schema.Column{TradeCorrectionsColumns[0]},
	}
	// TradeRecordsColumns holds the columns for the "trade_records" table.
	TradeRecordsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "price", Type: field.TypeFloat64},
		{Name: "timestamp", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "volume", Type: field.TypeInt32},
		{Name: "time_range_id", Type: field.TypeInt},
	}
	// TradeRecordsTable holds the schema information for the "trade_records" table.
	TradeRecordsTable = &schema.Table{
		Name:       "trade_records",
		Columns:    TradeRecordsColumns,
		PrimaryKey: []*schema.Column{TradeRecordsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "trade_records_trade_time_ranges_records",
				Columns:    []*schema.Column{TradeRecordsColumns[4]},
				RefColumns: []*schema.Column{TradeTimeRangesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "traderecord_time_range_id_timestamp",
				Unique:  true,
				Columns: []*schema.Column{TradeRecordsColumns[4], TradeRecordsColumns[2]},
			},
		},
	}
	// TradeTimeRangesColumns holds the columns for the "trade_time_ranges" table.
	TradeTimeRangesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "start", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "end", Type: field.TypeTime, SchemaType: map[string]string{"mysql": "datetime", "postgres": "date"}},
		{Name: "interval_id", Type: field.TypeInt},
	}
	// TradeTimeRangesTable holds the schema information for the "trade_time_ranges" table.
	TradeTimeRangesTable = &schema.Table{
		Name:       "trade_time_ranges",
		Columns:    TradeTimeRangesColumns,
		PrimaryKey: []*schema.Column{TradeTimeRangesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "trade_time_ranges_intervals_trades",
				Columns:    []*schema.Column{TradeTimeRangesColumns[3]},
				RefColumns: []*schema.Column{IntervalsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "tradetimerange_interval_id_start_end",
				Unique:  true,
				Columns: []*schema.Column{TradeTimeRangesColumns[3], TradeTimeRangesColumns[1], TradeTimeRangesColumns[2]},
			},
		},
	}
	// EntityExchangesColumns holds the columns for the "entity_exchanges" table.
	EntityExchangesColumns = []*schema.Column{
		{Name: "entity_id", Type: field.TypeInt},
		{Name: "exchange_id", Type: field.TypeInt},
	}
	// EntityExchangesTable holds the schema information for the "entity_exchanges" table.
	EntityExchangesTable = &schema.Table{
		Name:       "entity_exchanges",
		Columns:    EntityExchangesColumns,
		PrimaryKey: []*schema.Column{EntityExchangesColumns[0], EntityExchangesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "entity_exchanges_entity_id",
				Columns:    []*schema.Column{EntityExchangesColumns[0]},
				RefColumns: []*schema.Column{EntitiesColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "entity_exchanges_exchange_id",
				Columns:    []*schema.Column{EntityExchangesColumns[1]},
				RefColumns: []*schema.Column{ExchangesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// EntityDividendsColumns holds the columns for the "entity_dividends" table.
	EntityDividendsColumns = []*schema.Column{
		{Name: "entity_id", Type: field.TypeInt},
		{Name: "dividend_id", Type: field.TypeInt},
	}
	// EntityDividendsTable holds the schema information for the "entity_dividends" table.
	EntityDividendsTable = &schema.Table{
		Name:       "entity_dividends",
		Columns:    EntityDividendsColumns,
		PrimaryKey: []*schema.Column{EntityDividendsColumns[0], EntityDividendsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "entity_dividends_entity_id",
				Columns:    []*schema.Column{EntityDividendsColumns[0]},
				RefColumns: []*schema.Column{EntitiesColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "entity_dividends_dividend_id",
				Columns:    []*schema.Column{EntityDividendsColumns[1]},
				RefColumns: []*schema.Column{DividendsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// EntityFinancialsColumns holds the columns for the "entity_financials" table.
	EntityFinancialsColumns = []*schema.Column{
		{Name: "entity_id", Type: field.TypeInt},
		{Name: "financial_id", Type: field.TypeInt},
	}
	// EntityFinancialsTable holds the schema information for the "entity_financials" table.
	EntityFinancialsTable = &schema.Table{
		Name:       "entity_financials",
		Columns:    EntityFinancialsColumns,
		PrimaryKey: []*schema.Column{EntityFinancialsColumns[0], EntityFinancialsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "entity_financials_entity_id",
				Columns:    []*schema.Column{EntityFinancialsColumns[0]},
				RefColumns: []*schema.Column{EntitiesColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "entity_financials_financial_id",
				Columns:    []*schema.Column{EntityFinancialsColumns[1]},
				RefColumns: []*schema.Column{FinancialsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// TradeRecordConditionsColumns holds the columns for the "trade_record_conditions" table.
	TradeRecordConditionsColumns = []*schema.Column{
		{Name: "trade_record_id", Type: field.TypeInt},
		{Name: "trade_condition_id", Type: field.TypeInt},
	}
	// TradeRecordConditionsTable holds the schema information for the "trade_record_conditions" table.
	TradeRecordConditionsTable = &schema.Table{
		Name:       "trade_record_conditions",
		Columns:    TradeRecordConditionsColumns,
		PrimaryKey: []*schema.Column{TradeRecordConditionsColumns[0], TradeRecordConditionsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "trade_record_conditions_trade_record_id",
				Columns:    []*schema.Column{TradeRecordConditionsColumns[0]},
				RefColumns: []*schema.Column{TradeRecordsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "trade_record_conditions_trade_condition_id",
				Columns:    []*schema.Column{TradeRecordConditionsColumns[1]},
				RefColumns: []*schema.Column{TradeConditionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// TradeRecordCorrectionColumns holds the columns for the "trade_record_correction" table.
	TradeRecordCorrectionColumns = []*schema.Column{
		{Name: "trade_record_id", Type: field.TypeInt},
		{Name: "trade_correction_id", Type: field.TypeInt},
	}
	// TradeRecordCorrectionTable holds the schema information for the "trade_record_correction" table.
	TradeRecordCorrectionTable = &schema.Table{
		Name:       "trade_record_correction",
		Columns:    TradeRecordCorrectionColumns,
		PrimaryKey: []*schema.Column{TradeRecordCorrectionColumns[0], TradeRecordCorrectionColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "trade_record_correction_trade_record_id",
				Columns:    []*schema.Column{TradeRecordCorrectionColumns[0]},
				RefColumns: []*schema.Column{TradeRecordsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "trade_record_correction_trade_correction_id",
				Columns:    []*schema.Column{TradeRecordCorrectionColumns[1]},
				RefColumns: []*schema.Column{TradeCorrectionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		BarGroupsTable,
		BarRecordsTable,
		BarTimeRangesTable,
		DataSourcesTable,
		DividendsTable,
		EntitiesTable,
		ExchangesTable,
		FinancialsTable,
		IntervalsTable,
		MarketHoursTable,
		MarketInfosTable,
		SplitsTable,
		TradeConditionsTable,
		TradeCorrectionsTable,
		TradeRecordsTable,
		TradeTimeRangesTable,
		EntityExchangesTable,
		EntityDividendsTable,
		EntityFinancialsTable,
		TradeRecordConditionsTable,
		TradeRecordCorrectionTable,
	}
)

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