// ensure tables are in sync before each operation
openMetaTab(`Tables metadata is in sync`);
before(()=>{
openMetaTab();
});
after(()=>{
closeMetaTab();
})
});
it(`Create table`,()=>{
// Create Table
cy.task("queryDb",`CREATE TABLE sakila.table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`);
cy.task("queryDb",`CREATE TABLE sakila.table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`);
metaSyncValidate('out of sync','added');
})
cy.task(
"queryDb",
`CREATE TABLE sakila.table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
);
cy.task(
"queryDb",
`CREATE TABLE sakila.table2 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
);
metaSyncValidate("table1","New table");
// metaSyncValidate("table2", "Table added");
});
it(`Add relation`,()=>{
// Add relation (FK)
cy.task("queryDb",`ALTER TABLE sakila.table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE`)
cy.task("queryDb",`ALTER TABLE sakila.table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES sakila.table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION`);
cy.task(
"queryDb",
`ALTER TABLE sakila.table1 ADD INDEX fk1_idx (col1 ASC) VISIBLE`
);
cy.task(
"queryDb",
`ALTER TABLE sakila.table1 ADD CONSTRAINT fk1 FOREIGN KEY (col1) REFERENCES sakila.table2 (id) ON DELETE NO ACTION ON UPDATE NO ACTION`
);
// fix me
metaSyncValidate('in sync');
})
metaSyncValidate("table1","New relation added");
});
it(`Remove relation`,()=>{
// Remove relation (FK)
cy.task("queryDb",`ALTER TABLE sakila.table1 DROP FOREIGN KEY fk1`);
cy.task("queryDb",`ALTER TABLE sakila.table1 DROP INDEX fk1_idx`);
// fix me
metaSyncValidate('in sync');
})
metaSyncValidate("table1","Relation removed");
});
it(`Add column`,()=>{
// Add Column
cy.task("queryDb",`ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`);
cy.task(
"queryDb",
`ALTER TABLE sakila.table1 ADD COLUMN newCol VARCHAR(45) NULL AFTER id`