mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: default user from init .env variables (#293)
* fix: default user from init en .env variables * fix: .env.example --------- Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>
This commit is contained in:
co-authored by
charles-gauthereau
parent
332540488d
commit
7d463d7da8
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user