mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
* fix: default user from init en .env variables * fix: .env.example --------- Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>
27 lines
770 B
TypeScript
27 lines
770 B
TypeScript
import {db} from "@/db";
|
|
import * as drizzleDb from "@/db";
|
|
import {eq} from "drizzle-orm";
|
|
import {logger} from "@/lib/logger";
|
|
|
|
const log = logger.child({module: "init/organization"});
|
|
|
|
export async function createDefaultOrganization() {
|
|
const defaultOrganizationConf = {
|
|
slug: "default",
|
|
name: "Default Organization",
|
|
createdAt: new Date(),
|
|
};
|
|
|
|
const [existing] = await db
|
|
.select()
|
|
.from(drizzleDb.schemas.organization)
|
|
.where(eq(drizzleDb.schemas.organization.slug, "default"))
|
|
.limit(1);
|
|
|
|
if (!existing) {
|
|
log.info("==== Creating default Organization... ====");
|
|
await db
|
|
.insert(drizzleDb.schemas.organization)
|
|
.values(defaultOrganizationConf);
|
|
}
|
|
} |