lang-database 13.1.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[purchaseToken]` on the table `purchases` will be added. If there are existing duplicate values, this will fail.
5
+
6
+ */
7
+ -- CreateIndex
8
+ CREATE UNIQUE INDEX "purchases_purchaseToken_key" ON "purchases"("purchaseToken");
@@ -0,0 +1,2 @@
1
+ -- AlterEnum
2
+ ALTER TYPE "PurchaseState" ADD VALUE 'CANCELED';
@@ -0,0 +1,15 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - Changed the type of `state` on the `purchases` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
5
+
6
+ */
7
+ -- CreateEnum
8
+ CREATE TYPE "SubscriptionState" AS ENUM ('PENDING', 'COMPLETED', 'REFUNDED', 'FAILED', 'CANCELED');
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "purchases" DROP COLUMN "state",
12
+ ADD COLUMN "state" "SubscriptionState" NOT NULL;
13
+
14
+ -- DropEnum
15
+ DROP TYPE "PurchaseState";
@@ -0,0 +1,32 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `purchases` table. If the table is not empty, all the data it contains will be lost.
5
+
6
+ */
7
+ -- DropForeignKey
8
+ ALTER TABLE "purchases" DROP CONSTRAINT "purchases_userId_fkey";
9
+
10
+ -- DropTable
11
+ DROP TABLE "purchases";
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "subscriptions" (
15
+ "id" TEXT NOT NULL,
16
+ "userId" TEXT NOT NULL,
17
+ "purchaseToken" TEXT NOT NULL,
18
+ "sku" TEXT NOT NULL,
19
+ "state" "SubscriptionState" NOT NULL,
20
+ "acknowledged" BOOLEAN NOT NULL,
21
+ "expirationDate" TIMESTAMP(3) NOT NULL,
22
+ "createdAt" TIMESTAMP(3) NOT NULL,
23
+ "updatedAt" TIMESTAMP(3) NOT NULL,
24
+
25
+ CONSTRAINT "subscriptions_pkey" PRIMARY KEY ("id")
26
+ );
27
+
28
+ -- CreateIndex
29
+ CREATE UNIQUE INDEX "subscriptions_purchaseToken_key" ON "subscriptions"("purchaseToken");
30
+
31
+ -- AddForeignKey
32
+ ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,10 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `expirationDate` on the `subscriptions` table. All the data in the column will be lost.
5
+ - Added the required column `expiryTime` to the `subscriptions` table without a default value. This is not possible if the table is not empty.
6
+
7
+ */
8
+ -- AlterTable
9
+ ALTER TABLE "subscriptions" DROP COLUMN "expirationDate",
10
+ ADD COLUMN "expiryTime" TIMESTAMP(3) NOT NULL;
@@ -0,0 +1,14 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The values [COMPLETED,REFUNDED,FAILED,CANCELED] on the enum `SubscriptionState` will be removed. If these variants are still used in the database, this will fail.
5
+
6
+ */
7
+ -- AlterEnum
8
+ BEGIN;
9
+ CREATE TYPE "SubscriptionState_new" AS ENUM ('PENDING', 'ACTIVE', 'INACTIVE');
10
+ ALTER TABLE "subscriptions" ALTER COLUMN "state" TYPE "SubscriptionState_new" USING ("state"::text::"SubscriptionState_new");
11
+ ALTER TYPE "SubscriptionState" RENAME TO "SubscriptionState_old";
12
+ ALTER TYPE "SubscriptionState_new" RENAME TO "SubscriptionState";
13
+ DROP TYPE "SubscriptionState_old";
14
+ COMMIT;
package/package.json CHANGED
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "name": "lang-database",
3
- "version": "13.1.0",
3
+ "version": "14.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
8
  "create-migration": "npx prisma migrate dev --create-only",
9
+ "migrate": "npx prisma migrate deploy",
9
10
  "generate": "npx prisma generate",
10
- "push-dev-dbs": "npm run push-dev-db && npm run push-local-db && npm run push-test-db",
11
- "push-prod-db": "copy .env-prod .env && prisma db push --skip-generate",
12
- "push-dev-db": "copy .env-dev .env && prisma db push --skip-generate",
13
- "push-local-db": "copy .env-local .env && prisma db push --skip-generate",
14
- "push-test-db": "copy .env-test .env && prisma db push --skip-generate",
11
+ "push": "prisma db push --skip-generate",
15
12
  "test": "echo \"Error: no test specified\" && exit 1",
16
13
  "postinstall": "npm run generate"
17
14
  },
package/schema.prisma CHANGED
@@ -104,7 +104,7 @@ model User {
104
104
  password String?
105
105
  googleUser GoogleUser?
106
106
  achievements Achievement[]
107
- purchases Purchase[]
107
+ subscriptions Subscription[]
108
108
  userCards UserCard[]
109
109
  userDecks UserDeck[]
110
110
  userStat UserStat?
@@ -185,24 +185,23 @@ enum Answer {
185
185
  UNKNOWN
186
186
  }
187
187
 
188
- enum PurchaseState {
188
+ enum SubscriptionState {
189
189
  PENDING
190
- COMPLETED
191
- REFUNDED
192
- FAILED
190
+ ACTIVE
191
+ INACTIVE
193
192
  }
194
193
 
195
- model Purchase {
194
+ model Subscription {
196
195
  id String @id @default(cuid())
197
196
  user User @relation(fields: [userId], references: [id])
198
197
  userId String
199
198
  purchaseToken String @unique
200
199
  sku String
201
- state PurchaseState
200
+ state SubscriptionState
202
201
  acknowledged Boolean
203
- expirationDate DateTime
202
+ expiryTime DateTime
204
203
  createdAt DateTime
205
204
  updatedAt DateTime
206
205
 
207
- @@map("purchases")
206
+ @@map("subscriptions")
208
207
  }