Skip to content

Commit

Permalink
to postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Mar 30, 2024
1 parent 8971ed5 commit 7c26411
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 65 deletions.
38 changes: 0 additions & 38 deletions prisma/migrations/20240330182704_/migration.sql

This file was deleted.

50 changes: 50 additions & 0 deletions prisma/migrations/20240330222807_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Organizations" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"displayName" TEXT NOT NULL,

CONSTRAINT "Organizations_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "OrganizationsPeople" (
"userId" INTEGER NOT NULL,
"organizationId" INTEGER NOT NULL,

CONSTRAINT "OrganizationsPeople_pkey" PRIMARY KEY ("userId","organizationId")
);

-- CreateTable
CREATE TABLE "Apps" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"displayName" TEXT NOT NULL,
"osType" INTEGER NOT NULL,
"organizationsId" INTEGER NOT NULL,

CONSTRAINT "Apps_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Organizations_name_key" ON "Organizations"("name");

-- CreateIndex
CREATE UNIQUE INDEX "Apps_organizationsId_name_key" ON "Apps"("organizationsId", "name");

-- AddForeignKey
ALTER TABLE "OrganizationsPeople" ADD CONSTRAINT "OrganizationsPeople_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "OrganizationsPeople" ADD CONSTRAINT "OrganizationsPeople_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Apps" ADD CONSTRAINT "Apps_organizationsId_fkey" FOREIGN KEY ("organizationsId") REFERENCES "Organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"
provider = "postgresql"
16 changes: 8 additions & 8 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// datasource db {
// provider = "postgresql"
// // url = "postgresql://postgres:Qwerty@123@localhost:5432/AppDeployin"
// url = env("DATABASE_URL")
// }

datasource db {
provider = "sqlite"
url = "file:./data/app.db"
provider = "postgresql"
// url = "postgresql://postgres:Qwerty@123@localhost:5432/AppDeployin"
url = env("DATABASE_URL")
}

// datasource db {
// provider = "sqlite"
// url = "file:./data/app.db"
// }

generator clientWorker {
provider = "prisma-client-js"
}
Expand Down
18 changes: 0 additions & 18 deletions server/plugins/startup.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
import fs from 'fs';
import path from 'path'

export default defineNitroPlugin(async (nuxtApp) => {
tryMigrateSqliteDb()
})

function tryMigrateSqliteDb() {
console.log('Start tryMigrateSqliteDb')
const dir = process.cwd()
const appDbFile = path.join(dir, 'prisma', 'data', 'app.db')
if (fs.existsSync(appDbFile)) {
console.log('Ignoring copying migration db, already exists')
} else {
console.log('Copying migration db')
const dbMigrationFile = path.join(dir, '.temp', 'app.db')
fs.copyFileSync(dbMigrationFile, appDbFile)
}
console.log('Done tryMigrateSqliteDb')
}

0 comments on commit 7c26411

Please sign in to comment.