Exemple #1
0
func (aa *AddAttrTables) newTableStructure(tableName string) (*csdb.Table, error) {
	tableName = ReplaceTablePrefix(tableName)
	cols, err := GetColumns(aa.db, tableName)
	if err != nil {
		return nil, errgo.Mask(err)
	}
	return csdb.NewTable(tableName, cols.CopyToCSDB()...), nil
}
Exemple #2
0
func init() {
	tableMap = csdb.NewTableManager()
	tableMap.Append(
		table1,
		csdb.NewTable(
			"catalog_category_anc_categs_index_idx",
			csdb.Column{
				Field:   dbr.NewNullString("category_id"),
				Type:    dbr.NewNullString("int(10) unsigned"),
				Null:    dbr.NewNullString("NO"),
				Key:     dbr.NewNullString("MUL"),
				Default: dbr.NewNullString("0"),
				Extra:   dbr.NewNullString(""),
			},
			csdb.Column{
				Field:   dbr.NewNullString("path"),
				Type:    dbr.NewNullString("varchar(255)"),
				Null:    dbr.NewNullString("YES"),
				Key:     dbr.NewNullString("MUL"),
				Default: dbr.NullString{},
				Extra:   dbr.NewNullString(""),
			},
		),
	)
	tableMap.Append(
		table2,
		csdb.NewTable(
			"catalog_category_anc_categs_index_tmp",
			csdb.Column{
				Field:   dbr.NewNullString("category_id"),
				Type:    dbr.NewNullString("int(10) unsigned"),
				Null:    dbr.NewNullString("NO"),
				Key:     dbr.NewNullString("PRI"),
				Default: dbr.NewNullString("0"),
				Extra:   dbr.NewNullString(""),
			},
			csdb.Column{
				Field:   dbr.NewNullString("path"),
				Type:    dbr.NewNullString("varchar(255)"),
				Null:    dbr.NewNullString("YES"),
				Key:     dbr.NewNullString(nil),
				Default: dbr.NullString{},
				Extra:   dbr.NewNullString(""),
			},
		),
	)
	tableMap.Append(table3, csdb.NewTable(
		"catalog_category_anc_products_index_idx",
		csdb.Column{
			Field:   dbr.NewNullString("category_id"),
			Type:    dbr.NewNullString("int(10) unsigned"),
			Null:    dbr.NewNullString("NO"),
			Key:     dbr.NewNullString(nil),
			Default: dbr.NewNullString("0"),
			Extra:   dbr.NewNullString(""),
		},
		csdb.Column{
			Field:   dbr.NewNullString("product_id"),
			Type:    dbr.NewNullString("int(10) unsigned"),
			Null:    dbr.NewNullString("NO"),
			Key:     dbr.NewNullString(""),
			Default: dbr.NewNullString("0"),
			Extra:   dbr.NewNullString(""),
		},
		csdb.Column{
			Field:   dbr.NewNullString("position"),
			Type:    dbr.NewNullString("int(10) unsigned"),
			Null:    dbr.NewNullString("YES"),
			Key:     dbr.NewNullString(""),
			Default: dbr.NullString{},
			Extra:   dbr.NewNullString(""),
		},
	),
	)
	tableMap.Append(table4, csdb.NewTable(
		"admin_user",
		csdb.Column{
			Field:   dbr.NewNullString("user_id"),
			Type:    dbr.NewNullString("int(10) unsigned"),
			Null:    dbr.NewNullString("NO"),
			Key:     dbr.NewNullString("PRI"),
			Default: dbr.NullString{},
			Extra:   dbr.NewNullString("auto_increment"),
		},
		csdb.Column{
			Field:   dbr.NewNullString("email"),
			Type:    dbr.NewNullString("varchar(128)"),
			Null:    dbr.NewNullString("YES"),
			Key:     dbr.NewNullString(""),
			Default: dbr.NullString{},
			Extra:   dbr.NewNullString(""),
		},
		csdb.Column{
			Field:   dbr.NewNullString("username"),
			Type:    dbr.NewNullString("varchar(40)"),
			Null:    dbr.NewNullString("YES"),
			Key:     dbr.NewNullString("UNI"),
			Default: dbr.NullString{},
			Extra:   dbr.NewNullString(""),
		},
	),
	)
}