Documentation ¶
Overview ¶
Package sqlserver handles schema and data migrations from sqlserver.
Index ¶
- func ConvertData(conv *internal.Conv, tableId string, colIds []string, srcSchema schema.Table, ...) (string, []string, []interface{}, error)
- func ProcessDataRow(conv *internal.Conv, tableId string, colIds []string, srcSchema schema.Table, ...)
- type InfoSchemaImpl
- func (isi InfoSchemaImpl) GetColumns(conv *internal.Conv, table common.SchemaAndName, ...) (map[string]schema.Column, []string, error)
- func (isi InfoSchemaImpl) GetConstraints(conv *internal.Conv, table common.SchemaAndName) ([]string, map[string][]string, error)
- func (isi InfoSchemaImpl) GetForeignKeys(conv *internal.Conv, table common.SchemaAndName) (foreignKeys []schema.ForeignKey, err error)
- func (isi InfoSchemaImpl) GetIndexes(conv *internal.Conv, table common.SchemaAndName, ...) ([]schema.Index, error)
- func (isi InfoSchemaImpl) GetRowCount(table common.SchemaAndName) (int64, error)
- func (isi InfoSchemaImpl) GetRowsFromTable(conv *internal.Conv, tableId string) (interface{}, error)
- func (isi InfoSchemaImpl) GetTableName(schema string, tableName string) string
- func (isi InfoSchemaImpl) GetTables() ([]common.SchemaAndName, error)
- func (isi InfoSchemaImpl) GetToDdl() common.ToDdl
- func (isi InfoSchemaImpl) ProcessData(conv *internal.Conv, tableId string, srcSchema schema.Table, ...) error
- func (isi InfoSchemaImpl) StartChangeDataCapture(ctx context.Context, conv *internal.Conv) (map[string]interface{}, error)
- func (isi InfoSchemaImpl) StartStreamingMigration(ctx context.Context, client *sp.Client, conv *internal.Conv, ...) error
- type ToDdlImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertData ¶
func ConvertData(conv *internal.Conv, tableId string, colIds []string, srcSchema schema.Table, spSchema ddl.CreateTable, vals []string) (string, []string, []interface{}, error)
ConvertData maps the source DB data in vals into Spanner data, based on the Spanner and source DB schemas. Note that since entries in vals may be empty, we also return the list of columns (empty cols are dropped).
func ProcessDataRow ¶
func ProcessDataRow(conv *internal.Conv, tableId string, colIds []string, srcSchema schema.Table, spSchema ddl.CreateTable, vals []string)
ProcessDataRow converts a row of data and writes it out to Spanner. srcTable and srcCols are the source table and columns respectively, and vals contains string data to be converted to appropriate types to send to Spanner. ProcessDataRow is only called in DataMode.
Types ¶
type InfoSchemaImpl ¶
func (InfoSchemaImpl) GetColumns ¶
func (isi InfoSchemaImpl) GetColumns(conv *internal.Conv, table common.SchemaAndName, constraints map[string][]string, primaryKeys []string) (map[string]schema.Column, []string, error)
GetColumns returns a list of Column objects and names
func (InfoSchemaImpl) GetConstraints ¶
func (isi InfoSchemaImpl) GetConstraints(conv *internal.Conv, table common.SchemaAndName) ([]string, map[string][]string, error)
GetConstraints returns a list of primary keys and by-column map of other constraints. Note: we need to preserve ordinal order of columns in primary key constraints. Note that foreign key constraints are handled in getForeignKeys.
func (InfoSchemaImpl) GetForeignKeys ¶
func (isi InfoSchemaImpl) GetForeignKeys(conv *internal.Conv, table common.SchemaAndName) (foreignKeys []schema.ForeignKey, err error)
GetForeignKeys returns a list of all the foreign key constraints.
func (InfoSchemaImpl) GetIndexes ¶
func (isi InfoSchemaImpl) GetIndexes(conv *internal.Conv, table common.SchemaAndName, colNameIdMap map[string]string) ([]schema.Index, error)
GetIndexes return a list of all indexes for the specified table.
func (InfoSchemaImpl) GetRowCount ¶
func (isi InfoSchemaImpl) GetRowCount(table common.SchemaAndName) (int64, error)
GetRowCount with number of rows in each table.
func (InfoSchemaImpl) GetRowsFromTable ¶
func (isi InfoSchemaImpl) GetRowsFromTable(conv *internal.Conv, tableId string) (interface{}, error)
GetRowsFromTable returns a sql Rows object for a table.
func (InfoSchemaImpl) GetTableName ¶
func (isi InfoSchemaImpl) GetTableName(schema string, tableName string) string
GetTableName returns table name.
func (InfoSchemaImpl) GetTables ¶
func (isi InfoSchemaImpl) GetTables() ([]common.SchemaAndName, error)
GetTables return list of tables in the selected database.
func (InfoSchemaImpl) GetToDdl ¶
func (isi InfoSchemaImpl) GetToDdl() common.ToDdl
GetToDdl function below implement the common.InfoSchema interface.
func (InfoSchemaImpl) ProcessData ¶
func (isi InfoSchemaImpl) ProcessData(conv *internal.Conv, tableId string, srcSchema schema.Table, commonColIds []string, spSchema ddl.CreateTable, additionalAttributes internal.AdditionalDataAttributes) error
ProcessDataRows performs data conversion for source database 'db'. For each table, we extract data using a "SELECT *" query, convert the data to Spanner data (based on the source and Spanner schemas), and write it to Spanner. If we can't get/process data for a table, we skip that table and process the remaining tables.
Note that the database/sql library has a somewhat complex model for returning data from rows.Scan. Scalar values can be returned using the native value used by the underlying driver (by passing *interface{} to rows.Scan), or they can be converted to specific go types. We choose to do all type conversions explicitly ourselves so that we can generate more targeted error messages: hence we pass *interface{} parameters to row.Scan.
func (InfoSchemaImpl) StartChangeDataCapture ¶
func (isi InfoSchemaImpl) StartChangeDataCapture(ctx context.Context, conv *internal.Conv) (map[string]interface{}, error)
We leave the 2 functions below empty to be able to pass this as an infoSchema interface. We don't need these for now.
type ToDdlImpl ¶
type ToDdlImpl struct { }
ToDdlImpl sql server specific implementation for ToDdl.
func (ToDdlImpl) ToSpannerType ¶
func (tdi ToDdlImpl) ToSpannerType(conv *internal.Conv, spType string, srcType schema.Type) (ddl.Type, []internal.SchemaIssue)
ToSpannerType maps a scalar source schema type (defined by id and mods) into a Spanner type. This is the core source-to-Spanner type mapping. toSpannerType returns the Spanner type and a list of type conversion issues encountered.