44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import createDatabase from "../functions/createDatabase";
|
|
import createDatabaseNode from "../functions/createDatabaseNode";
|
|
import createMigration from "../functions/createMigration";
|
|
import createProject from "../functions/createProject";
|
|
import databaseMigrationUp from "..//functions/databaseMigrationUp";
|
|
|
|
(async () => {
|
|
try {
|
|
const node = await createDatabaseNode("localhost", 3306, "root", "root");
|
|
|
|
console.log("Database node created:", node);
|
|
|
|
const project = await createProject("Test Migrations Project");
|
|
|
|
console.log("Project created:", project);
|
|
|
|
const db = await createDatabase(project.id, node.id);
|
|
|
|
console.log("Database created:", db);
|
|
|
|
const migration = await createMigration(
|
|
db.id,
|
|
"CREATE TABLE `test` (id INT)",
|
|
"DROP TABLE `test`"
|
|
);
|
|
|
|
console.log("Migration created:", migration);
|
|
|
|
const migration2 = await createMigration(
|
|
db.id,
|
|
"ALTER TABLE `test` ADD COLUMN name VARCHAR(255)",
|
|
"ALTER TABLE `test` DROP COLUMN name"
|
|
);
|
|
|
|
console.log("Second Migration created:", migration2);
|
|
|
|
const migrationsUp = await databaseMigrationUp(db.id);
|
|
|
|
console.log("Migrations applied:", migrationsUp);
|
|
} catch (error) {
|
|
console.error("Error during test execution:", error);
|
|
}
|
|
})();
|