dialect/sql/schema: index builders per dialect

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/118

Reviewed By: alexsn

Differential Revision: D18092371

fbshipit-source-id: 02b85724b1e00d10c930112b9e2c8d07c8727216
This commit is contained in:
Ariel Mashraki
2019-10-24 02:22:49 -07:00
committed by Facebook Github Bot
parent c414cd9a82
commit 88bfbc38df
6 changed files with 176 additions and 20 deletions

View File

@@ -61,11 +61,19 @@ func (d *SQLite) setRange(ctx context.Context, tx dialect.Tx, name string, value
return tx.Exec(ctx, query, args, new(sql.Result))
}
// fkExist returns always true to disable foreign-keys creation after the table was created.
func (d *SQLite) fkExist(context.Context, dialect.Tx, string) (bool, error) { return true, nil }
func (d *SQLite) table(context.Context, dialect.Tx, string) (*Table, error) { return nil, nil }
func (*SQLite) cType(c *Column) string { return c.SQLiteType() }
func (*SQLite) tBuilder(t *Table) *sql.TableBuilder { return t.SQLite() }
func (*SQLite) addColumn(c *Column) *sql.ColumnBuilder { return c.SQLite() }
func (*SQLite) alterColumn(c *Column) []*sql.ColumnBuilder { return []*sql.ColumnBuilder{c.SQLite()} }
// fkExist returns always tru to disable foreign-keys creation after the table was created.
func (d *SQLite) fkExist(context.Context, dialect.Tx, string) (bool, error) { return true, nil }
func (d *SQLite) table(context.Context, dialect.Tx, string) (*Table, error) { return nil, nil }
func (d *SQLite) addIndex(i *Index, table string) *sql.IndexBuilder {
return i.Builder(table)
}
func (d *SQLite) dropIndex(i *Index, _ string) *sql.DropIndexBuilder {
return i.DropBuilder("")
}