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.
- package/migrations/20250108155517_renamed_purchase_to_subscription/migration.sql +15 -0
- package/migrations/20250108155747_reamed_table_as_well/migration.sql +32 -0
- package/migrations/20250108164441_renamed_expiration/migration.sql +10 -0
- package/migrations/20250108164603_introduced_new_subscription_states/migration.sql +14 -0
- package/package.json +1 -1
- package/schema.prisma +8 -10
|
@@ -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
package/schema.prisma
CHANGED
|
@@ -104,7 +104,7 @@ model User {
|
|
|
104
104
|
password String?
|
|
105
105
|
googleUser GoogleUser?
|
|
106
106
|
achievements Achievement[]
|
|
107
|
-
|
|
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
|
|
188
|
+
enum SubscriptionState {
|
|
189
189
|
PENDING
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
FAILED
|
|
193
|
-
CANCELED
|
|
190
|
+
ACTIVE
|
|
191
|
+
INACTIVE
|
|
194
192
|
}
|
|
195
193
|
|
|
196
|
-
model
|
|
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
|
|
200
|
+
state SubscriptionState
|
|
203
201
|
acknowledged Boolean
|
|
204
|
-
|
|
202
|
+
expiryTime DateTime
|
|
205
203
|
createdAt DateTime
|
|
206
204
|
updatedAt DateTime
|
|
207
205
|
|
|
208
|
-
@@map("
|
|
206
|
+
@@map("subscriptions")
|
|
209
207
|
}
|