-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
286 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Config" ADD COLUMN "encryption_key" TEXT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Config" ADD COLUMN "first_time_setup" BOOLEAN NOT NULL DEFAULT true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Warnings: | ||
- The `encryption_key` column on the `Config` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "Config" DROP COLUMN "encryption_key", | ||
ADD COLUMN "encryption_key" BYTEA; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,59 @@ | ||
const { PrismaClient } = require("@prisma/client"); | ||
const crypto = require("crypto"); | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
await prisma.user.upsert({ | ||
where: { email: "[email protected]" }, | ||
update: {}, | ||
create: { | ||
email: `[email protected]`, | ||
name: "admin", | ||
isAdmin: true, | ||
password: "$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu", | ||
language: "en", | ||
}, | ||
}); | ||
const setup = await prisma.config.findFirst({}); | ||
|
||
await prisma.client.upsert({ | ||
where: { email: `[email protected]` }, | ||
update: {}, | ||
create: { | ||
email: `[email protected]`, | ||
name: "internal", | ||
contactName: "admin", | ||
number: "123456789", | ||
active: true, | ||
}, | ||
}); | ||
if (setup === null) { | ||
await prisma.user.upsert({ | ||
where: { email: "[email protected]" }, | ||
update: {}, | ||
create: { | ||
email: `[email protected]`, | ||
name: "admin", | ||
isAdmin: true, | ||
password: | ||
"$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu", | ||
language: "en", | ||
}, | ||
}); | ||
|
||
await prisma.client.upsert({ | ||
where: { email: `[email protected]` }, | ||
update: {}, | ||
create: { | ||
email: `[email protected]`, | ||
name: "internal", | ||
contactName: "admin", | ||
number: "123456789", | ||
active: true, | ||
}, | ||
}); | ||
|
||
const encryptionKey = crypto.randomBytes(32); // Generates a random key | ||
|
||
const conf = await prisma.config.create({ | ||
data: { | ||
gh_version: "0.3.6", | ||
client_version: "0.3.6", | ||
portal_locale: "en", | ||
encryption_key: encryptionKey, | ||
}, | ||
}); | ||
|
||
await prisma.config.update({ | ||
where: { | ||
id: conf.id, | ||
}, | ||
data: { | ||
first_time_setup: false, | ||
}, | ||
}); | ||
} else { | ||
console.log("No need to seed, already seeded"); | ||
} | ||
} | ||
|
||
main() | ||
|
Oops, something went wrong.