mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 05:28:51 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Knex } from "knex";
|
|
|
|
import { TableName } from "../schemas";
|
|
import { seedData1 } from "../seed-data";
|
|
|
|
export const DEFAULT_PROJECT_ENVS = [
|
|
{ name: "Development", slug: "dev" },
|
|
{ name: "Staging", slug: "staging" },
|
|
{ name: "Production", slug: "prod" }
|
|
];
|
|
|
|
export async function seed(knex: Knex): Promise<void> {
|
|
// Deletes ALL existing entries
|
|
await knex(TableName.Project).del();
|
|
await knex(TableName.Environment).del();
|
|
await knex(TableName.SecretFolder).del();
|
|
|
|
const [project] = await knex(TableName.Project)
|
|
.insert({
|
|
name: seedData1.project.name,
|
|
orgId: seedData1.organization.id,
|
|
// @ts-ignore pre calc id
|
|
id: seedData1.project.id
|
|
})
|
|
.returning("*");
|
|
const envs = await knex(TableName.Environment)
|
|
.insert(
|
|
DEFAULT_PROJECT_ENVS.map(({ name, slug }, index) => ({
|
|
name,
|
|
slug,
|
|
projectId: project.id,
|
|
position: index + 1
|
|
}))
|
|
)
|
|
.returning("*");
|
|
await knex(TableName.SecretFolder).insert(
|
|
envs.map(({ id }) => ({ name: "root", envId: id, parentId: null }))
|
|
);
|
|
}
|