Social assets: no auto table create, manual SQL only
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,19 +22,9 @@ const ALLOWED_MIME_TYPES = new Set([
|
||||
'video/mp4',
|
||||
]);
|
||||
|
||||
// Schema changes in this repo are applied as raw SQL against the running
|
||||
// database (no Prisma migrations); this keeps the route self-bootstrapping.
|
||||
async function ensureTable() {
|
||||
await db.$executeRawUnsafe(`
|
||||
CREATE TABLE IF NOT EXISTS "SocialAsset" (
|
||||
"id" TEXT PRIMARY KEY,
|
||||
"filename" TEXT NOT NULL,
|
||||
"mimeType" TEXT NOT NULL,
|
||||
"data" BYTEA NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
`);
|
||||
}
|
||||
// The "SocialAsset" table is NOT created by this route. Apply the schema
|
||||
// manually on the server (npm run docker:db), see
|
||||
// docs/automations/social-accounts-and-jobs.md.
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
if (!isAdminRequest(request)) {
|
||||
@@ -82,8 +72,6 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
try {
|
||||
await ensureTable();
|
||||
|
||||
const baseUrl = process.env.NEXTAUTH_URL || 'https://qrmaster.net';
|
||||
const assets = [];
|
||||
for (const file of files) {
|
||||
@@ -114,7 +102,6 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
try {
|
||||
await ensureTable();
|
||||
const assets = await db.socialAsset.findMany({
|
||||
select: { id: true, filename: true, mimeType: true, createdAt: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
|
||||
Reference in New Issue
Block a user