lang-database 13.1.1 → 15.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/migrations/20250307234904_new_user_stat_fields/migration.sql +22 -0
- package/package.json +3 -3
- package/schema.prisma +15 -15
- package/migration.dump +0 -64
|
@@ -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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `dailyUsageSec` on the `userStats` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the column `monthlyUsageSec` on the `userStats` table. All the data in the column will be lost.
|
|
6
|
+
- You are about to drop the column `weeklyUsageSec` on the `userStats` table. All the data in the column will be lost.
|
|
7
|
+
- Added the required column `thisMonthActiveDays` to the `userStats` table without a default value. This is not possible if the table is not empty.
|
|
8
|
+
- Added the required column `thisMonthActivitySec` to the `userStats` table without a default value. This is not possible if the table is not empty.
|
|
9
|
+
- Added the required column `thisWeekActiveDays` to the `userStats` table without a default value. This is not possible if the table is not empty.
|
|
10
|
+
- Added the required column `thisWeekActivitySec` to the `userStats` table without a default value. This is not possible if the table is not empty.
|
|
11
|
+
- Added the required column `todayActivitySec` to the `userStats` table without a default value. This is not possible if the table is not empty.
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
-- AlterTable
|
|
15
|
+
ALTER TABLE "userStats" DROP COLUMN "dailyUsageSec",
|
|
16
|
+
DROP COLUMN "monthlyUsageSec",
|
|
17
|
+
DROP COLUMN "weeklyUsageSec",
|
|
18
|
+
ADD COLUMN "thisMonthActiveDays" INTEGER NOT NULL,
|
|
19
|
+
ADD COLUMN "thisMonthActivitySec" INTEGER NOT NULL,
|
|
20
|
+
ADD COLUMN "thisWeekActiveDays" INTEGER NOT NULL,
|
|
21
|
+
ADD COLUMN "thisWeekActivitySec" INTEGER NOT NULL,
|
|
22
|
+
ADD COLUMN "todayActivitySec" INTEGER NOT NULL;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lang-database",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"create
|
|
9
|
-
"migrate": "npx prisma migrate deploy",
|
|
8
|
+
"migrate:create": "npx prisma migrate dev --create-only",
|
|
9
|
+
"migrate:deploy": "npx prisma migrate deploy",
|
|
10
10
|
"generate": "npx prisma generate",
|
|
11
11
|
"push": "prisma db push --skip-generate",
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
package/schema.prisma
CHANGED
|
@@ -60,11 +60,13 @@ model UserStat {
|
|
|
60
60
|
user User @relation(fields: [userId], references: [id])
|
|
61
61
|
userId String
|
|
62
62
|
|
|
63
|
-
lastAnswerTimestamp
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
lastAnswerTimestamp DateTime
|
|
64
|
+
todayActivitySec Int
|
|
65
|
+
thisWeekActivitySec Int
|
|
66
|
+
thisWeekActiveDays Int
|
|
67
|
+
thisMonthActivitySec Int
|
|
68
|
+
thisMonthActiveDays Int
|
|
69
|
+
cardsDone Int
|
|
68
70
|
|
|
69
71
|
@@id([userId])
|
|
70
72
|
@@map("userStats")
|
|
@@ -104,7 +106,7 @@ model User {
|
|
|
104
106
|
password String?
|
|
105
107
|
googleUser GoogleUser?
|
|
106
108
|
achievements Achievement[]
|
|
107
|
-
|
|
109
|
+
subscriptions Subscription[]
|
|
108
110
|
userCards UserCard[]
|
|
109
111
|
userDecks UserDeck[]
|
|
110
112
|
userStat UserStat?
|
|
@@ -185,25 +187,23 @@ enum Answer {
|
|
|
185
187
|
UNKNOWN
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
enum
|
|
190
|
+
enum SubscriptionState {
|
|
189
191
|
PENDING
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
FAILED
|
|
193
|
-
CANCELED
|
|
192
|
+
ACTIVE
|
|
193
|
+
INACTIVE
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
model
|
|
196
|
+
model Subscription {
|
|
197
197
|
id String @id @default(cuid())
|
|
198
198
|
user User @relation(fields: [userId], references: [id])
|
|
199
199
|
userId String
|
|
200
200
|
purchaseToken String @unique
|
|
201
201
|
sku String
|
|
202
|
-
state
|
|
202
|
+
state SubscriptionState
|
|
203
203
|
acknowledged Boolean
|
|
204
|
-
|
|
204
|
+
expiryTime DateTime
|
|
205
205
|
createdAt DateTime
|
|
206
206
|
updatedAt DateTime
|
|
207
207
|
|
|
208
|
-
@@map("
|
|
208
|
+
@@map("subscriptions")
|
|
209
209
|
}
|
package/migration.dump
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
--
|
|
2
|
-
-- PostgreSQL database dump
|
|
3
|
-
--
|
|
4
|
-
|
|
5
|
-
-- Dumped from database version 17.2
|
|
6
|
-
-- Dumped by pg_dump version 17.2
|
|
7
|
-
|
|
8
|
-
SET statement_timeout = 0;
|
|
9
|
-
SET lock_timeout = 0;
|
|
10
|
-
SET idle_in_transaction_session_timeout = 0;
|
|
11
|
-
SET transaction_timeout = 0;
|
|
12
|
-
SET client_encoding = 'UTF8';
|
|
13
|
-
SET standard_conforming_strings = on;
|
|
14
|
-
SELECT pg_catalog.set_config('search_path', '', false);
|
|
15
|
-
SET check_function_bodies = false;
|
|
16
|
-
SET xmloption = content;
|
|
17
|
-
SET client_min_messages = warning;
|
|
18
|
-
SET row_security = off;
|
|
19
|
-
|
|
20
|
-
SET default_tablespace = '';
|
|
21
|
-
|
|
22
|
-
SET default_table_access_method = heap;
|
|
23
|
-
|
|
24
|
-
--
|
|
25
|
-
-- Name: _prisma_migrations; Type: TABLE; Schema: public; Owner: postgres
|
|
26
|
-
--
|
|
27
|
-
|
|
28
|
-
CREATE TABLE public._prisma_migrations (
|
|
29
|
-
id character varying(36) NOT NULL,
|
|
30
|
-
checksum character varying(64) NOT NULL,
|
|
31
|
-
finished_at timestamp with time zone,
|
|
32
|
-
migration_name character varying(255) NOT NULL,
|
|
33
|
-
logs text,
|
|
34
|
-
rolled_back_at timestamp with time zone,
|
|
35
|
-
started_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
36
|
-
applied_steps_count integer DEFAULT 0 NOT NULL
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ALTER TABLE public._prisma_migrations OWNER TO postgres;
|
|
41
|
-
|
|
42
|
-
--
|
|
43
|
-
-- Data for Name: _prisma_migrations; Type: TABLE DATA; Schema: public; Owner: postgres
|
|
44
|
-
--
|
|
45
|
-
|
|
46
|
-
COPY public._prisma_migrations (id, checksum, finished_at, migration_name, logs, rolled_back_at, started_at, applied_steps_count) FROM stdin;
|
|
47
|
-
3652124e-dce1-4770-999a-d04dff20fe9f b39a05144c141af535ebe7e2e6ffc5dd8d7c617ecedd049d0b6cc9ef20b7875e 2024-12-14 00:01:40.689448+01 20241205175825_init \N \N 2024-12-14 00:01:40.642657+01 1
|
|
48
|
-
ab846b6b-ee1b-4b3e-b1bb-31375fdbdc13 2f6dac4b7b4b8ace1f589a7c073a0003a0cd390ef7188cbd7657ec967da86f41 2024-12-14 00:01:40.698333+01 20241210212001_ \N \N 2024-12-14 00:01:40.689987+01 1
|
|
49
|
-
29f01ddb-11d8-4490-85c1-0cbcb950360c c40ba2f55a4e327af2e1904a26ae12d7823a1627eee8bcbbfbaa689ac8c00f07 2024-12-14 00:01:40.710179+01 20241213210059_new_purchase_table \N \N 2024-12-14 00:01:40.70724+01 1
|
|
50
|
-
\.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
--
|
|
54
|
-
-- Name: _prisma_migrations _prisma_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
|
55
|
-
--
|
|
56
|
-
|
|
57
|
-
ALTER TABLE ONLY public._prisma_migrations
|
|
58
|
-
ADD CONSTRAINT _prisma_migrations_pkey PRIMARY KEY (id);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
--
|
|
62
|
-
-- PostgreSQL database dump complete
|
|
63
|
-
--
|
|
64
|
-
|