Fix merge issue flexible backend (#1685)

* Fix merge issue flexible backend

* Fix tests

* Try fix tests

* Try fix tests
This commit is contained in:
Charles Bochet
2023-09-20 19:11:21 -07:00
committed by GitHub
parent 19365f6639
commit 2d758c990b
14 changed files with 98 additions and 46 deletions

View File

@ -0,0 +1,56 @@
// check-db.ts
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
const createMetadataSchema = async () => {
try {
await prisma.$queryRawUnsafe<[any]>(
`CREATE SCHEMA IF NOT EXISTS "metadata";`,
);
await prisma.$queryRawUnsafe<[any]>(
`GRANT ALL ON SCHEMA metadata TO twenty;`,
);
return true;
} catch {
return false;
}
};
const activateUUIDExtension = async () => {
try {
const result = await prisma.$queryRawUnsafe<[any]>(
`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`,
);
return result;
} catch {
return false;
}
};
const main = async () => {
const metadataSchemaCreationSuccess = await createMetadataSchema();
const uuidExtensionActivationSuccess = await activateUUIDExtension();
if (!metadataSchemaCreationSuccess) {
throw new Error(`Failed to create metadata schema`);
}
if (!uuidExtensionActivationSuccess) {
throw new Error(`Failed to activate uuid extension`);
}
};
main()
.then(() => {
process.exit(0);
})
.catch(() => {
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});