mirror of
https://github.com/harness/drone.git
synced 2025-05-19 02:20:03 +08:00
Fix index operation tests
This commit is contained in:
parent
489e38908a
commit
d61bb3ef6c
@ -125,12 +125,12 @@ func (r *revision4) Revision() int64 {
|
|||||||
type revision5 struct{}
|
type revision5 struct{}
|
||||||
|
|
||||||
func (r *revision5) Up(mg *MigrationDriver) error {
|
func (r *revision5) Up(mg *MigrationDriver) error {
|
||||||
_, err := mg.Tx.Exec(`CREATE INDEX samples_url_name_ix ON samples (url, name)`)
|
_, err := mg.AddIndex("samples", []string{"url", "name"}, "")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *revision5) Down(mg *MigrationDriver) error {
|
func (r *revision5) Down(mg *MigrationDriver) error {
|
||||||
_, err := mg.Tx.Exec(`DROP INDEX samples_url_name_ix`)
|
_, err := mg.DropIndex("samples", []string{"url", "name"})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,9 +442,9 @@ func TestIndexOperations(t *testing.T) {
|
|||||||
t.Errorf("Can not find index: %q", err)
|
t.Errorf("Can not find index: %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
indexStatement := `CREATE INDEX samples_url_name_ix ON samples (url, name)`
|
indexStatement := `CREATE INDEX idx_samples_on_url_and_name ON samples (url, name)`
|
||||||
if string(esquel[1].Sql.([]byte)) != indexStatement {
|
if string(esquel[1].Sql.([]byte)) != indexStatement {
|
||||||
t.Errorf("Can not find index")
|
t.Errorf("Can not find index, got: %q", esquel[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate, rename indexed columns
|
// Migrate, rename indexed columns
|
||||||
@ -457,9 +457,9 @@ func TestIndexOperations(t *testing.T) {
|
|||||||
t.Errorf("Can not find index: %q", err)
|
t.Errorf("Can not find index: %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
indexStatement = `CREATE INDEX samples_host_name_ix ON samples (host, name)`
|
indexStatement = `CREATE INDEX idx_samples_on_host_and_name ON samples (host, name)`
|
||||||
if string(esquel1[1].Sql.([]byte)) != indexStatement {
|
if string(esquel1[1].Sql.([]byte)) != indexStatement {
|
||||||
t.Errorf("Can not find index, got: %s", esquel[0])
|
t.Errorf("Can not find index, got: %q", esquel1[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mgr.Add(&revision7{}).Migrate(); err != nil {
|
if err := mgr.Add(&revision7{}).Migrate(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user