Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
25 lines
846 B
Plaintext
25 lines
846 B
Plaintext
export const migrationTableExists = async (adapter, db)=>{
|
|
let statement;
|
|
if (adapter.name === 'postgres') {
|
|
const prependSchema = adapter.schemaName ? `"${adapter.schemaName}".` : '';
|
|
statement = `SELECT to_regclass('${prependSchema}"payload_migrations"') AS exists;`;
|
|
}
|
|
if (adapter.name === 'sqlite') {
|
|
statement = `
|
|
SELECT CASE
|
|
WHEN COUNT(*) > 0 THEN 1
|
|
ELSE 0
|
|
END AS 'exists'
|
|
FROM sqlite_master
|
|
WHERE type = 'table'
|
|
AND name = 'payload_migrations';`;
|
|
}
|
|
const result = await adapter.execute({
|
|
drizzle: db ?? adapter.drizzle,
|
|
raw: statement
|
|
});
|
|
const [row] = result.rows;
|
|
return row && typeof row === 'object' && 'exists' in row && !!row.exists;
|
|
};
|
|
|
|
//# sourceMappingURL=migrationTableExists.js.map |