Skip to content

Commit

Permalink
only seed once
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Oct 16, 2023
1 parent bcd0a1c commit a07510f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"snyk-protect": "snyk protect",
"start-test-server": "./bin/start_ci_test_server.sh",
"start:api:dev": "nx start:dev @altairgraphql/api",
"start:api:prod": "yarn --cwd packages/altair-db prisma migrate deploy && yarn --cwd packages/altair-api start:prod",
"start:api:prod": "yarn --cwd packages/altair-db prisma migrate deploy && yarn --cwd packages/altair-db prisma db seed && yarn --cwd packages/altair-api start:prod",
"start:app": "nx start @altairgraphql/app",
"start:dashboard": "nx dev @altairgraphql/dashboard",
"start:redirect": "nx dev @altairgraphql/login-redirect",
Expand Down
28 changes: 20 additions & 8 deletions packages/altair-db/src/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ import { BASIC_PLAN_ID } from './constants';
const prisma = new PrismaClient();

async function main() {
// create the basic plan config
const basicPlan = await prisma.planConfig.create({
data: {
const basicPlanExists = await prisma.planConfig.findUnique({
where: {
id: BASIC_PLAN_ID,
maxQueryCount: 20,
maxTeamCount: 1,
maxTeamMemberCount: 2,
allowMoreTeamMembers: false,
},
});

console.log({ basicPlan });
if (!basicPlanExists) {
await createBasicPlan();
}
}

// execute the main function
Expand All @@ -30,6 +27,21 @@ main()
await prisma.$disconnect();
});

async function createBasicPlan() {
// create the basic plan config
const basicPlan = await prisma.planConfig.create({
data: {
id: BASIC_PLAN_ID,
maxQueryCount: 20,
maxTeamCount: 1,
maxTeamMemberCount: 2,
allowMoreTeamMembers: false,
},
});

console.log({ basicPlan });
}

async function createTeamWorkspaces() {
const teamsWithoutWorkspace = await prisma.team.findMany({
where: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { PersistentStore } from '../store';
export const initMainProcessStoreEvents = () => {
const store = new PersistentStore();

ipcMain.on(STORE_EVENTS.LENGTH, (e) => {
ipcMain.on(STORE_EVENTS.LENGTH, e => {
e.returnValue = store.size;
});

ipcMain.on(STORE_EVENTS.CLEAR, (e) => {
ipcMain.on(STORE_EVENTS.CLEAR, e => {
e.returnValue = store.clear();
});

Expand All @@ -30,7 +30,7 @@ export const initMainProcessStoreEvents = () => {
e.returnValue = store.set(key, value);
});

ipcMain.on(STORE_EVENTS.GET_STORE_OBJECT, (e) => {
ipcMain.on(STORE_EVENTS.GET_STORE_OBJECT, e => {
e.returnValue = store.store;
});
};

0 comments on commit a07510f

Please sign in to comment.