diff --git a/src/build/mod.ts b/src/build/mod.ts index 40148600..ce30c635 100644 --- a/src/build/mod.ts +++ b/src/build/mod.ts @@ -249,6 +249,7 @@ async function buildSteps( buildStep(buildState, { name: `Migrate`, module, + // TODO: Also watch migrations folder in case a migration is created/destroyed files: [resolve(module.path, "db", "schema.prisma")], async build() { if ("local" in module.registry.config) { diff --git a/tests/test_project/backend.yaml b/tests/test_project/backend.yaml index 8725245d..4b1e8087 100644 --- a/tests/test_project/backend.yaml +++ b/tests/test_project/backend.yaml @@ -1,21 +1,15 @@ registries: - # default: - # local: - # directory: ../../../opengb-registry/modules + default: + local: + directory: ../../../opengb-registry/modules local: local: directory: ./modules modules: - # currency: {} - # friends: {} - # rate_limit: {} - # tokens: {} + currency: {} + friends: {} + rate_limit: {} + tokens: {} users: {} - # auth: - # config: - # google: - # token: abc123 - # discord: - # token: abc123 foo: registry: local diff --git a/tests/test_project/modules/foo/db/migrations/20240304094519_/migration.sql b/tests/test_project/modules/foo/db/migrations/20240304094519_/migration.sql deleted file mode 100644 index e579acd2..00000000 --- a/tests/test_project/modules/foo/db/migrations/20240304094519_/migration.sql +++ /dev/null @@ -1,35 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" UUID NOT NULL, - "username" TEXT NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Identity" ( - "id" UUID NOT NULL, - "userId" UUID NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Identity_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "IdentityGuest" ( - "identityId" UUID NOT NULL, - - CONSTRAINT "IdentityGuest_pkey" PRIMARY KEY ("identityId") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); - --- CreateIndex -CREATE UNIQUE INDEX "IdentityGuest_identityId_key" ON "IdentityGuest"("identityId"); - --- AddForeignKey -ALTER TABLE "Identity" ADD CONSTRAINT "Identity_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "IdentityGuest" ADD CONSTRAINT "IdentityGuest_identityId_fkey" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/tests/test_project/modules/foo/db/migrations/20240306224507_init/migration.sql b/tests/test_project/modules/foo/db/migrations/20240306224507_init/migration.sql deleted file mode 100644 index 00a1c2a3..00000000 --- a/tests/test_project/modules/foo/db/migrations/20240306224507_init/migration.sql +++ /dev/null @@ -1,29 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Identity` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `IdentityGuest` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropForeignKey -ALTER TABLE "Identity" DROP CONSTRAINT "Identity_userId_fkey"; - --- DropForeignKey -ALTER TABLE "IdentityGuest" DROP CONSTRAINT "IdentityGuest_identityId_fkey"; - --- DropTable -DROP TABLE "Identity"; - --- DropTable -DROP TABLE "IdentityGuest"; - --- DropTable -DROP TABLE "User"; - --- CreateTable -CREATE TABLE "DbEntry" ( - "id" UUID NOT NULL, - - CONSTRAINT "DbEntry_pkey" PRIMARY KEY ("id") -); diff --git a/tests/test_project/modules/foo/db/migrations/20240307013756_init/migration.sql b/tests/test_project/modules/foo/db/migrations/20240307013756_init/migration.sql new file mode 100644 index 00000000..b5310af0 --- /dev/null +++ b/tests/test_project/modules/foo/db/migrations/20240307013756_init/migration.sql @@ -0,0 +1,6 @@ +-- CreateTable +CREATE TABLE "DbEntry" ( + "id" UUID NOT NULL, + + CONSTRAINT "DbEntry_pkey" PRIMARY KEY ("id") +);