fix: removed seed scripts

This commit is contained in:
Mir Arif Hasan
2023-01-24 12:49:22 +06:00
parent bc82e9c7fa
commit e8e176ed40
3 changed files with 1 additions and 69 deletions

View File

@@ -1,15 +0,0 @@
-- CreateTable
CREATE TABLE "UserSettings" (
"id" TEXT NOT NULL,
"userUid" TEXT NOT NULL,
"settings" JSONB NOT NULL,
"updatedOn" TIMESTAMP(3) NOT NULL,
CONSTRAINT "UserSettings_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "UserSettings_userUid_key" ON "UserSettings"("userUid");
-- AddForeignKey
ALTER TABLE "UserSettings" ADD CONSTRAINT "UserSettings_userUid_fkey" FOREIGN KEY ("userUid") REFERENCES "User"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -1,53 +0,0 @@
import { PrismaClient, User, UserSettings } from '@prisma/client';
const prisma = new PrismaClient();
const createUsers = async () => {
console.log(`Creating new users`);
const users: User[] = [
{
uid: 'aabb22ccdd',
displayName: 'exampleUser',
photoURL: 'http://example.com/avatar',
email: 'me@example.com',
},
];
await prisma.user.createMany({
data: users,
skipDuplicates: true,
});
console.log(`users created`);
};
const createUserSettings = async () => {
console.log(`Creating user settings property`);
const userSettings: any[] = [
{
userUid: 'aabb22ccdd',
settings: { key: 'background', value: 'system' },
},
];
await prisma.userSettings.createMany({
data: userSettings,
skipDuplicates: true,
});
console.log(`user setting created`);
};
async function main() {
console.log(`Start seeding ...`);
await createUsers();
await createUserSettings();
console.log(`Seeding finished.`);
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});

View File

@@ -59,7 +59,7 @@ export class UserSettingsResolver {
/* Subscriptions */
@Subscription(() => UserSettings, {
description: 'Listen for user setting creates',
description: 'Listen for user setting creation',
resolve: (value) => value,
})
@UseGuards(GqlAuthGuard)