add platform demo fam
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { SCHEMA_PLAN } from '@shared/pb/schema';
|
||||
import { PB_ENDPOINT } from '$lib/server/pocketbase';
|
||||
import { PB_EMAIL, PB_PASSWORD, MEMBER_SECRET } from '$app/env/private';
|
||||
import { getPlatformFlags } from '$lib/server/platform';
|
||||
|
||||
let token: string | null = null;
|
||||
let tokenExpiry = 0;
|
||||
@@ -20,6 +21,11 @@ async function auth(): Promise<string> {
|
||||
return token!;
|
||||
}
|
||||
|
||||
async function isDemo(): Promise<boolean> {
|
||||
const flags = await getPlatformFlags();
|
||||
return flags.demo === true;
|
||||
}
|
||||
|
||||
async function getCollection(name: string): Promise<any | null> {
|
||||
const t = await auth();
|
||||
const res = await fetch(`${PB_ENDPOINT}/api/collections?filter=name='${name}'`, {
|
||||
@@ -444,8 +450,10 @@ export async function migrate(): Promise<void> {
|
||||
await ensureAccessCodes();
|
||||
await ensurePlatform();
|
||||
await ensureDefaultSeasons();
|
||||
await seedDemoFamily();
|
||||
await seedDemoCompletions();
|
||||
if (await isDemo()) {
|
||||
await seedDemoFamily();
|
||||
await seedDemoCompletions();
|
||||
}
|
||||
console.log('[migrate] Done');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user