-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8971ed5
commit 7c26411
Showing
5 changed files
with
59 additions
and
65 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} |