lang-database 13.1.1 → 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,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,6 +1,6 @@
1
1
  {
2
2
  "name": "lang-database",
3
- "version": "13.1.1",
3
+ "version": "14.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
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,25 +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
193
- CANCELED
190
+ ACTIVE
191
+ INACTIVE
194
192
  }
195
193
 
196
- model Purchase {
194
+ model Subscription {
197
195
  id String @id @default(cuid())
198
196
  user User @relation(fields: [userId], references: [id])
199
197
  userId String
200
198
  purchaseToken String @unique
201
199
  sku String
202
- state PurchaseState
200
+ state SubscriptionState
203
201
  acknowledged Boolean
204
- expirationDate DateTime
202
+ expiryTime DateTime
205
203
  createdAt DateTime
206
204
  updatedAt DateTime
207
205
 
208
- @@map("purchases")
206
+ @@map("subscriptions")
209
207
  }