Skip to content

Commit 3e0bf44

Browse files
changes done
1 parent d329a89 commit 3e0bf44

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"ghcr.io/devcontainers/features/github-cli": {}
6868
},
6969
"init": true,
70-
"initializeCommand": "wsl cp -n ./envFiles/.env.devcontainer ./.env",
70+
"initializeCommand": "/bin/sh -c '[ ! -f .env ] && cp ./envFiles/.env.devcontainer ./.env || true'",
7171
"name": "talawa_api",
7272
"overrideCommand": true,
7373
"postCreateCommand": "sudo chown talawa:talawa ./.pnpm-store ./node_modules && fnm install && fnm use && corepack enable npm && corepack enable && corepack install && pnpm install && pnpm start_development_server",

src/plugins/seedInitialData.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { hash } from "@node-rs/argon2";
2-
import { eq, isNotNull, name } from "drizzle-orm";
2+
import { and, eq, isNotNull, sql } from "drizzle-orm";
33
import type { FastifyPluginAsync } from "fastify";
44
import fastifyPlugin from "fastify-plugin";
55
import { uuidv7 } from "uuidv7";
@@ -17,8 +17,7 @@ import {
1717
organizationsTableInsertSchema,
1818
} from "~/src/drizzle/tables/organizations";
1919
import { usersTable, usersTableInsertSchema } from "~/src/drizzle/tables/users";
20-
// import { organizationsTable } from "../drizzle/schema";
21-
// import { organizationsTableInsertSchema } from "../drizzle/tables/organizations";
20+
2221
/**
2322
* This plugin handles seeding the initial data into appropriate service at the startup time of the talawa api. The data must strictly only comprise of things that are required in the production environment of talawa api. This plugin shouldn't be used for seeding dummy data.
2423
*
@@ -190,7 +189,13 @@ const plugin: FastifyPluginAsync = async (fastify) => {
190189
const organizationExists = await fastify.drizzleClient
191190
.select({ addressLine1: organizationsTable.addressLine1 })
192191
.from(organizationsTable)
193-
.where(isNotNull(organizationsTable.addressLine1))
192+
.where(
193+
and(
194+
isNotNull(organizationsTable.addressLine1),
195+
sql`char_length(${organizationsTable.addressLine1}) > 0`,
196+
),
197+
)
198+
194199
.limit(1)
195200
.then((result) => result.length > 0);
196201

0 commit comments

Comments
 (0)