@s-hirano-ist/s-database 0.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.
Files changed (61) hide show
  1. package/LICENSE +661 -0
  2. package/package.json +49 -0
  3. package/prisma/migrations/20241005070905_initial_with_user/migration.sql +105 -0
  4. package/prisma/migrations/20241005122052_category_unique_name/migration.sql +11 -0
  5. package/prisma/migrations/20241006114119_add_role/migration.sql +5 -0
  6. package/prisma/migrations/20241011230910_add_scope_and_username/migration.sql +24 -0
  7. package/prisma/migrations/20241012012914_migrate_user_verified_to_role/migration.sql +11 -0
  8. package/prisma/migrations/20241012014828_delete_user_email/migration.sql +11 -0
  9. package/prisma/migrations/20241013122009_delete_unique_on_profile_name/migration.sql +2 -0
  10. package/prisma/migrations/20241113115839_add_image_table/migration.sql +13 -0
  11. package/prisma/migrations/20241116050545_login_lock/migration.sql +3 -0
  12. package/prisma/migrations/20250104003943_delete_user_scope_column/migration.sql +11 -0
  13. package/prisma/migrations/20250104031930_delete_unauthorized_role_enum/migration.sql +16 -0
  14. package/prisma/migrations/20250104033736_change_user_role_enum_name/migration.sql +19 -0
  15. package/prisma/migrations/20250104064405_add_static_books_and_contents/migration.sql +27 -0
  16. package/prisma/migrations/20250113084254_drop_user_table/migration.sql +37 -0
  17. package/prisma/migrations/20250118084244_add_image_metadata/migration.sql +14 -0
  18. package/prisma/migrations/20250129231002_add_static_image_table/migration.sql +14 -0
  19. package/prisma/migrations/20250504020635_add_static_news_table/migration.sql +27 -0
  20. package/prisma/migrations/20250510025039_fix_no_unique_for_categories/migration.sql +2 -0
  21. package/prisma/migrations/20250614000736_add_google_api_data/migration.sql +31 -0
  22. package/prisma/migrations/20250719061839_add_og_for_static_news/migration.sql +4 -0
  23. package/prisma/migrations/20250730114244_delete_uint8arrayimage_from_static_books/migration.sql +8 -0
  24. package/prisma/migrations/20250811111733_delete_static_news/migration.sql +20 -0
  25. package/prisma/migrations/20250811115459_delete_updated_recently/migration.sql +34 -0
  26. package/prisma/migrations/20250811131348_merge_viewer_to_dumper/migration.sql +54 -0
  27. package/prisma/migrations/20250812234654_add_unique_costraints_on_unique_key/migration.sql +19 -0
  28. package/prisma/migrations/20250813033448_add_unique_constraints_on_images/migration.sql +8 -0
  29. package/prisma/migrations/20250813085846_delete_single_unique_constraints/migration.sql +5 -0
  30. package/prisma/migrations/20250813140904_change_id_from_int_to_uuid/migration.sql +27 -0
  31. package/prisma/migrations/20250813141347_move_image_id_to_paths/migration.sql +15 -0
  32. package/prisma/migrations/20250815002544_change_default_values/migration.sql +39 -0
  33. package/prisma/migrations/20250815040824_rename_images_paths_to_path/migration.sql +17 -0
  34. package/prisma/migrations/20250818232331_change_news_contents_to_article_note/migration.sql +57 -0
  35. package/prisma/migrations/20250819024722_delete_default_now_for_created_at/migration.sql +14 -0
  36. package/prisma/migrations/migration_lock.toml +3 -0
  37. package/prisma/schema.prisma +127 -0
  38. package/src/generated/client.d.ts +1 -0
  39. package/src/generated/client.js +5 -0
  40. package/src/generated/default.d.ts +1 -0
  41. package/src/generated/default.js +5 -0
  42. package/src/generated/edge.d.ts +1 -0
  43. package/src/generated/edge.js +264 -0
  44. package/src/generated/index-browser.js +251 -0
  45. package/src/generated/index.d.ts +8913 -0
  46. package/src/generated/index.js +279 -0
  47. package/src/generated/package.json +183 -0
  48. package/src/generated/runtime/edge-esm.js +35 -0
  49. package/src/generated/runtime/edge.js +35 -0
  50. package/src/generated/runtime/index-browser.d.ts +370 -0
  51. package/src/generated/runtime/index-browser.js +17 -0
  52. package/src/generated/runtime/library.d.ts +3982 -0
  53. package/src/generated/runtime/library.js +147 -0
  54. package/src/generated/runtime/react-native.js +84 -0
  55. package/src/generated/runtime/wasm-compiler-edge.js +85 -0
  56. package/src/generated/runtime/wasm-engine-edge.js +37 -0
  57. package/src/generated/schema.prisma +127 -0
  58. package/src/generated/wasm-edge-light-loader.mjs +5 -0
  59. package/src/generated/wasm-worker-loader.mjs +5 -0
  60. package/src/generated/wasm.d.ts +1 -0
  61. package/src/generated/wasm.js +264 -0
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@s-hirano-ist/s-database",
3
+ "version": "0.0.0",
4
+ "description": "Prisma database schema and client for s-private project",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./generated": "./src/generated/index.js",
14
+ "./generated/*": "./src/generated/*"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "src/generated",
22
+ "prisma",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/s-hirano-ist/s-private.git",
29
+ "directory": "packages/database"
30
+ },
31
+ "license": "AGPL-3.0",
32
+ "dependencies": {
33
+ "@prisma/client": "6.19.0",
34
+ "@prisma/extension-accelerate": "3.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "prisma": "6.19.0",
38
+ "typescript": "5.9.3"
39
+ },
40
+ "scripts": {
41
+ "prisma:generate": "prisma generate --no-engine",
42
+ "prisma:migrate": "prisma migrate dev",
43
+ "prisma:deploy": "prisma migrate deploy",
44
+ "prisma:studio": "prisma studio",
45
+ "build": "tsc",
46
+ "postinstall": "pnpm prisma:generate",
47
+ "clean": "rm -rf dist"
48
+ }
49
+ }
@@ -0,0 +1,105 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "Status" AS ENUM ('UNEXPORTED', 'UPDATED_RECENTLY', 'EXPORTED');
3
+
4
+ -- CreateTable
5
+ CREATE TABLE "users" (
6
+ "id" TEXT NOT NULL,
7
+ "email" TEXT NOT NULL,
8
+ "password" TEXT NOT NULL,
9
+ "verified" BOOLEAN NOT NULL DEFAULT false,
10
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
11
+ "updated_at" TIMESTAMP(3) NOT NULL,
12
+
13
+ CONSTRAINT "users_pkey" PRIMARY KEY ("id")
14
+ );
15
+
16
+ -- CreateTable
17
+ CREATE TABLE "profiles" (
18
+ "id" TEXT NOT NULL,
19
+ "name" TEXT,
20
+ "bio" TEXT,
21
+ "avatar_url" TEXT,
22
+ "user_id" TEXT NOT NULL,
23
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
24
+ "updated_at" TIMESTAMP(3) NOT NULL,
25
+
26
+ CONSTRAINT "profiles_pkey" PRIMARY KEY ("id")
27
+ );
28
+
29
+ -- CreateTable
30
+ CREATE TABLE "login_histories" (
31
+ "id" TEXT NOT NULL,
32
+ "user_id" TEXT NOT NULL,
33
+ "ip_address" TEXT,
34
+ "user_agent" TEXT,
35
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
36
+
37
+ CONSTRAINT "login_histories_pkey" PRIMARY KEY ("id")
38
+ );
39
+
40
+ -- CreateTable
41
+ CREATE TABLE "categories" (
42
+ "id" SERIAL NOT NULL,
43
+ "name" TEXT NOT NULL,
44
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
45
+ "updated_at" TIMESTAMP(3) NOT NULL,
46
+ "user_id" TEXT NOT NULL,
47
+
48
+ CONSTRAINT "categories_pkey" PRIMARY KEY ("id")
49
+ );
50
+
51
+ -- CreateTable
52
+ CREATE TABLE "news" (
53
+ "id" SERIAL NOT NULL,
54
+ "title" TEXT NOT NULL,
55
+ "url" TEXT NOT NULL,
56
+ "quote" TEXT,
57
+ "status" "Status" NOT NULL DEFAULT 'UNEXPORTED',
58
+ "category_id" INTEGER NOT NULL,
59
+ "userId" TEXT NOT NULL,
60
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
61
+ "updated_at" TIMESTAMP(3) NOT NULL,
62
+
63
+ CONSTRAINT "news_pkey" PRIMARY KEY ("id")
64
+ );
65
+
66
+ -- CreateTable
67
+ CREATE TABLE "contents" (
68
+ "id" SERIAL NOT NULL,
69
+ "title" TEXT NOT NULL,
70
+ "url" TEXT NOT NULL,
71
+ "quote" TEXT,
72
+ "status" "Status" NOT NULL DEFAULT 'UNEXPORTED',
73
+ "user_id" TEXT NOT NULL,
74
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
75
+ "updated_at" TIMESTAMP(3) NOT NULL,
76
+
77
+ CONSTRAINT "contents_pkey" PRIMARY KEY ("id")
78
+ );
79
+
80
+ -- CreateIndex
81
+ CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
82
+
83
+ -- CreateIndex
84
+ CREATE UNIQUE INDEX "profiles_user_id_key" ON "profiles"("user_id");
85
+
86
+ -- CreateIndex
87
+ CREATE UNIQUE INDEX "categories_name_key" ON "categories"("name");
88
+
89
+ -- AddForeignKey
90
+ ALTER TABLE "profiles" ADD CONSTRAINT "profiles_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
91
+
92
+ -- AddForeignKey
93
+ ALTER TABLE "login_histories" ADD CONSTRAINT "login_histories_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
94
+
95
+ -- AddForeignKey
96
+ ALTER TABLE "categories" ADD CONSTRAINT "categories_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
97
+
98
+ -- AddForeignKey
99
+ ALTER TABLE "news" ADD CONSTRAINT "news_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
100
+
101
+ -- AddForeignKey
102
+ ALTER TABLE "news" ADD CONSTRAINT "news_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
103
+
104
+ -- AddForeignKey
105
+ ALTER TABLE "contents" ADD CONSTRAINT "contents_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,11 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[name,user_id]` on the table `categories` will be added. If there are existing duplicate values, this will fail.
5
+
6
+ */
7
+ -- DropIndex
8
+ DROP INDEX "categories_name_key";
9
+
10
+ -- CreateIndex
11
+ CREATE UNIQUE INDEX "categories_name_user_id_key" ON "categories"("name", "user_id");
@@ -0,0 +1,5 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "Role" AS ENUM ('ADMIN', 'EDITOR', 'VIEWER');
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "users" ADD COLUMN "role" "Role" NOT NULL DEFAULT 'VIEWER';
@@ -0,0 +1,24 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[name]` on the table `profiles` will be added. If there are existing duplicate values, this will fail.
5
+ - A unique constraint covering the columns `[username]` on the table `users` will be added. If there are existing duplicate values, this will fail.
6
+ - Made the column `name` on table `profiles` required. This step will fail if there are existing NULL values in that column.
7
+ - Added the required column `username` to the `users` table without a default value. This is not possible if the table is not empty.
8
+
9
+ */
10
+ -- CreateEnum
11
+ CREATE TYPE "Scope" AS ENUM ('PUBLIC', 'PRIVATE');
12
+
13
+ -- AlterTable
14
+ ALTER TABLE "profiles" ALTER COLUMN "name" SET NOT NULL;
15
+
16
+ -- AlterTable
17
+ ALTER TABLE "users" ADD COLUMN "scope" "Scope" NOT NULL DEFAULT 'PUBLIC',
18
+ ADD COLUMN "username" TEXT NOT NULL;
19
+
20
+ -- CreateIndex
21
+ CREATE UNIQUE INDEX "profiles_name_key" ON "profiles"("name");
22
+
23
+ -- CreateIndex
24
+ CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
@@ -0,0 +1,11 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `verified` on the `users` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- AlterEnum
8
+ ALTER TYPE "Role" ADD VALUE 'UNAUTHORIZED';
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "users" DROP COLUMN "verified";
@@ -0,0 +1,11 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `email` on the `users` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- DropIndex
8
+ DROP INDEX "users_email_key";
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "users" DROP COLUMN "email";
@@ -0,0 +1,2 @@
1
+ -- DropIndex
2
+ DROP INDEX "profiles_name_key";
@@ -0,0 +1,13 @@
1
+ -- CreateTable
2
+ CREATE TABLE "images" (
3
+ "id" TEXT NOT NULL,
4
+ "status" "Status" NOT NULL DEFAULT 'UNEXPORTED',
5
+ "user_id" TEXT NOT NULL,
6
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7
+ "updated_at" TIMESTAMP(3) NOT NULL,
8
+
9
+ CONSTRAINT "images_pkey" PRIMARY KEY ("id")
10
+ );
11
+
12
+ -- AddForeignKey
13
+ ALTER TABLE "images" ADD CONSTRAINT "images_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,3 @@
1
+ -- AlterTable
2
+ ALTER TABLE "users" ADD COLUMN "failed_login_attempts" INTEGER NOT NULL DEFAULT 0,
3
+ ADD COLUMN "is_locked" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,11 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `scope` on the `users` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- AlterTable
8
+ ALTER TABLE "users" DROP COLUMN "scope";
9
+
10
+ -- DropEnum
11
+ DROP TYPE "Scope";
@@ -0,0 +1,16 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The values [UNAUTHORIZED] on the enum `Role` will be removed. If these variants are still used in the database, this will fail.
5
+
6
+ */
7
+ -- AlterEnum
8
+ BEGIN;
9
+ CREATE TYPE "Role_new" AS ENUM ('ADMIN', 'EDITOR', 'VIEWER');
10
+ ALTER TABLE "users" ALTER COLUMN "role" DROP DEFAULT;
11
+ ALTER TABLE "users" ALTER COLUMN "role" TYPE "Role_new" USING ("role"::text::"Role_new");
12
+ ALTER TYPE "Role" RENAME TO "Role_old";
13
+ ALTER TYPE "Role_new" RENAME TO "Role";
14
+ DROP TYPE "Role_old";
15
+ ALTER TABLE "users" ALTER COLUMN "role" SET DEFAULT 'VIEWER';
16
+ COMMIT;
@@ -0,0 +1,19 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The values [EDITOR] on the enum `Role` will be removed. If these variants are still used in the database, this will fail.
5
+
6
+ */
7
+ -- AlterEnum
8
+ BEGIN;
9
+ CREATE TYPE "Role_new" AS ENUM ('ADMIN', 'VIEWER', 'UNAUTHORIZED');
10
+ ALTER TABLE "users" ALTER COLUMN "role" DROP DEFAULT;
11
+ ALTER TABLE "users" ALTER COLUMN "role" TYPE "Role_new" USING ("role"::text::"Role_new");
12
+ ALTER TYPE "Role" RENAME TO "Role_old";
13
+ ALTER TYPE "Role_new" RENAME TO "Role";
14
+ DROP TYPE "Role_old";
15
+ ALTER TABLE "users" ALTER COLUMN "role" SET DEFAULT 'UNAUTHORIZED';
16
+ COMMIT;
17
+
18
+ -- AlterTable
19
+ ALTER TABLE "users" ALTER COLUMN "role" SET DEFAULT 'UNAUTHORIZED';
@@ -0,0 +1,27 @@
1
+ -- CreateTable
2
+ CREATE TABLE "st_contents" (
3
+ "title" TEXT NOT NULL,
4
+ "markdown" TEXT NOT NULL,
5
+ "uint8ArrayImage" BYTEA NOT NULL,
6
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7
+ "updated_at" TIMESTAMP(3) NOT NULL,
8
+
9
+ CONSTRAINT "st_contents_pkey" PRIMARY KEY ("title")
10
+ );
11
+
12
+ -- CreateTable
13
+ CREATE TABLE "st_books" (
14
+ "title" TEXT NOT NULL,
15
+ "markdown" TEXT NOT NULL,
16
+ "uint8ArrayImage" BYTEA NOT NULL,
17
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ "updated_at" TIMESTAMP(3) NOT NULL,
19
+
20
+ CONSTRAINT "st_books_pkey" PRIMARY KEY ("title")
21
+ );
22
+
23
+ -- CreateIndex
24
+ CREATE UNIQUE INDEX "st_contents_title_key" ON "st_contents"("title");
25
+
26
+ -- CreateIndex
27
+ CREATE UNIQUE INDEX "st_books_title_key" ON "st_books"("title");
@@ -0,0 +1,37 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `login_histories` table. If the table is not empty, all the data it contains will be lost.
5
+ - You are about to drop the `profiles` table. If the table is not empty, all the data it contains will be lost.
6
+ - You are about to drop the `users` table. If the table is not empty, all the data it contains will be lost.
7
+
8
+ */
9
+ -- DropForeignKey
10
+ ALTER TABLE "categories" DROP CONSTRAINT "categories_user_id_fkey";
11
+
12
+ -- DropForeignKey
13
+ ALTER TABLE "contents" DROP CONSTRAINT "contents_user_id_fkey";
14
+
15
+ -- DropForeignKey
16
+ ALTER TABLE "images" DROP CONSTRAINT "images_user_id_fkey";
17
+
18
+ -- DropForeignKey
19
+ ALTER TABLE "login_histories" DROP CONSTRAINT "login_histories_user_id_fkey";
20
+
21
+ -- DropForeignKey
22
+ ALTER TABLE "news" DROP CONSTRAINT "news_userId_fkey";
23
+
24
+ -- DropForeignKey
25
+ ALTER TABLE "profiles" DROP CONSTRAINT "profiles_user_id_fkey";
26
+
27
+ -- DropTable
28
+ DROP TABLE "login_histories";
29
+
30
+ -- DropTable
31
+ DROP TABLE "profiles";
32
+
33
+ -- DropTable
34
+ DROP TABLE "users";
35
+
36
+ -- DropEnum
37
+ DROP TYPE "Role";
@@ -0,0 +1,14 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - Added the required column `content_type` to the `images` table without a default value. This is not possible if the table is not empty.
5
+
6
+ */
7
+ -- AlterTable
8
+ ALTER TABLE "images" ADD COLUMN "content_type" TEXT NOT NULL,
9
+ ADD COLUMN "deleted_at" TIMESTAMP(3),
10
+ ADD COLUMN "description" TEXT,
11
+ ADD COLUMN "file_size" INTEGER,
12
+ ADD COLUMN "height" INTEGER,
13
+ ADD COLUMN "tags" TEXT[] DEFAULT ARRAY[]::TEXT[],
14
+ ADD COLUMN "width" INTEGER;
@@ -0,0 +1,14 @@
1
+ -- CreateTable
2
+ CREATE TABLE "st_images" (
3
+ "id" TEXT NOT NULL,
4
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
5
+ "updated_at" TIMESTAMP(3) NOT NULL,
6
+ "content_type" TEXT NOT NULL,
7
+ "file_size" INTEGER,
8
+ "width" INTEGER,
9
+ "height" INTEGER,
10
+ "tags" TEXT[] DEFAULT ARRAY[]::TEXT[],
11
+ "description" TEXT,
12
+
13
+ CONSTRAINT "st_images_pkey" PRIMARY KEY ("id")
14
+ );
@@ -0,0 +1,27 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[name]` on the table `categories` will be added. If there are existing duplicate values, this will fail.
5
+
6
+ */
7
+ -- CreateTable
8
+ CREATE TABLE "st_news" (
9
+ "id" SERIAL NOT NULL,
10
+ "url" TEXT NOT NULL,
11
+ "title" TEXT NOT NULL,
12
+ "quote" TEXT,
13
+ "category_id" INTEGER NOT NULL,
14
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
15
+ "updated_at" TIMESTAMP(3) NOT NULL,
16
+
17
+ CONSTRAINT "st_news_pkey" PRIMARY KEY ("url")
18
+ );
19
+
20
+ -- CreateIndex
21
+ CREATE UNIQUE INDEX "st_news_url_key" ON "st_news"("url");
22
+
23
+ -- CreateIndex
24
+ CREATE UNIQUE INDEX "categories_name_key" ON "categories"("name");
25
+
26
+ -- AddForeignKey
27
+ ALTER TABLE "st_news" ADD CONSTRAINT "st_news_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,2 @@
1
+ -- DropIndex
2
+ DROP INDEX "categories_name_key";
@@ -0,0 +1,31 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The primary key for the `st_books` table will be changed. If it partially fails, the table could be left without primary key constraint.
5
+ - A unique constraint covering the columns `[isbn]` on the table `st_books` will be added. If there are existing duplicate values, this will fail.
6
+ - Added the required column `google_description` to the `st_books` table without a default value. This is not possible if the table is not empty.
7
+ - Added the required column `google_href` to the `st_books` table without a default value. This is not possible if the table is not empty.
8
+ - Added the required column `google_img_src` to the `st_books` table without a default value. This is not possible if the table is not empty.
9
+ - Added the required column `google_subtitle` to the `st_books` table without a default value. This is not possible if the table is not empty.
10
+ - Added the required column `google_title` to the `st_books` table without a default value. This is not possible if the table is not empty.
11
+ - Added the required column `isbn` to the `st_books` table without a default value. This is not possible if the table is not empty.
12
+
13
+ */
14
+ -- DropIndex
15
+ DROP INDEX "st_books_title_key";
16
+
17
+ -- AlterTable
18
+ ALTER TABLE "st_books" DROP CONSTRAINT "st_books_pkey",
19
+ ADD COLUMN "google_authors" TEXT[],
20
+ ADD COLUMN "google_description" TEXT NOT NULL,
21
+ ADD COLUMN "google_href" TEXT NOT NULL,
22
+ ADD COLUMN "google_img_src" TEXT NOT NULL,
23
+ ADD COLUMN "google_subtitle" TEXT NOT NULL,
24
+ ADD COLUMN "google_title" TEXT NOT NULL,
25
+ ADD COLUMN "isbn" TEXT NOT NULL,
26
+ ADD COLUMN "rating" INTEGER,
27
+ ADD COLUMN "tags" TEXT[] DEFAULT ARRAY[]::TEXT[],
28
+ ADD CONSTRAINT "st_books_pkey" PRIMARY KEY ("isbn");
29
+
30
+ -- CreateIndex
31
+ CREATE UNIQUE INDEX "st_books_isbn_key" ON "st_books"("isbn");
@@ -0,0 +1,4 @@
1
+ -- AlterTable
2
+ ALTER TABLE "st_news" ADD COLUMN "og_description" TEXT,
3
+ ADD COLUMN "og_image_url" TEXT,
4
+ ADD COLUMN "og_title" TEXT;
@@ -0,0 +1,8 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `uint8ArrayImage` on the `st_books` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- AlterTable
8
+ ALTER TABLE "public"."st_books" DROP COLUMN "uint8ArrayImage";
@@ -0,0 +1,20 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `st_news` table. If the table is not empty, all the data it contains will be lost.
5
+ - A unique constraint covering the columns `[url]` on the table `news` will be added. If there are existing duplicate values, this will fail.
6
+
7
+ */
8
+ -- DropForeignKey
9
+ ALTER TABLE "public"."st_news" DROP CONSTRAINT "st_news_category_id_fkey";
10
+
11
+ -- AlterTable
12
+ ALTER TABLE "public"."news" ADD COLUMN "og_description" TEXT,
13
+ ADD COLUMN "og_image_url" TEXT,
14
+ ADD COLUMN "og_title" TEXT;
15
+
16
+ -- DropTable
17
+ DROP TABLE "public"."st_news";
18
+
19
+ -- CreateIndex
20
+ CREATE UNIQUE INDEX "news_url_key" ON "public"."news"("url");
@@ -0,0 +1,34 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The values [UPDATED_RECENTLY] on the enum `Status` will be removed. If these variants are still used in the database, this will fail.
5
+ - You are about to drop the column `deleted_at` on the `images` table. All the data in the column will be lost.
6
+ - You are about to drop the column `userId` on the `news` table. All the data in the column will be lost.
7
+ - Added the required column `user_id` to the `news` table without a default value. This is not possible if the table is not empty.
8
+
9
+ */
10
+ -- AlterEnum
11
+ BEGIN;
12
+ CREATE TYPE "public"."Status_new" AS ENUM ('UNEXPORTED', 'EXPORTED');
13
+ ALTER TABLE "public"."contents" ALTER COLUMN "status" DROP DEFAULT;
14
+ ALTER TABLE "public"."images" ALTER COLUMN "status" DROP DEFAULT;
15
+ ALTER TABLE "public"."news" ALTER COLUMN "status" DROP DEFAULT;
16
+ ALTER TABLE "public"."news" ALTER COLUMN "status" TYPE "public"."Status_new" USING ("status"::text::"public"."Status_new");
17
+ ALTER TABLE "public"."contents" ALTER COLUMN "status" TYPE "public"."Status_new" USING ("status"::text::"public"."Status_new");
18
+ ALTER TABLE "public"."images" ALTER COLUMN "status" TYPE "public"."Status_new" USING ("status"::text::"public"."Status_new");
19
+ ALTER TYPE "public"."Status" RENAME TO "Status_old";
20
+ ALTER TYPE "public"."Status_new" RENAME TO "Status";
21
+ DROP TYPE "public"."Status_old";
22
+ ALTER TABLE "public"."contents" ALTER COLUMN "status" SET DEFAULT 'UNEXPORTED';
23
+ ALTER TABLE "public"."images" ALTER COLUMN "status" SET DEFAULT 'UNEXPORTED';
24
+ ALTER TABLE "public"."news" ALTER COLUMN "status" SET DEFAULT 'UNEXPORTED';
25
+ COMMIT;
26
+
27
+ -- AlterTable
28
+ ALTER TABLE "public"."images" DROP COLUMN "deleted_at",
29
+ ADD COLUMN "exported_at" TIMESTAMP(3);
30
+
31
+ -- AlterTable
32
+ ALTER TABLE "public"."news" DROP COLUMN "userId",
33
+ ADD COLUMN "exported_at" TIMESTAMP(3),
34
+ ADD COLUMN "user_id" TEXT NOT NULL;
@@ -0,0 +1,54 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `quote` on the `contents` table. All the data in the column will be lost.
5
+ - You are about to drop the column `url` on the `contents` table. All the data in the column will be lost.
6
+ - You are about to drop the `st_books` table. If the table is not empty, all the data it contains will be lost.
7
+ - You are about to drop the `st_contents` table. If the table is not empty, all the data it contains will be lost.
8
+ - You are about to drop the `st_images` table. If the table is not empty, all the data it contains will be lost.
9
+ - A unique constraint covering the columns `[title]` on the table `contents` will be added. If there are existing duplicate values, this will fail.
10
+ - Added the required column `markdown` to the `contents` table without a default value. This is not possible if the table is not empty.
11
+
12
+ */
13
+ -- AlterTable
14
+ ALTER TABLE "public"."contents" DROP COLUMN "quote",
15
+ DROP COLUMN "url",
16
+ ADD COLUMN "exported_at" TIMESTAMP(3),
17
+ ADD COLUMN "markdown" TEXT NOT NULL;
18
+
19
+ -- DropTable
20
+ DROP TABLE "public"."st_books";
21
+
22
+ -- DropTable
23
+ DROP TABLE "public"."st_contents";
24
+
25
+ -- DropTable
26
+ DROP TABLE "public"."st_images";
27
+
28
+ -- CreateTable
29
+ CREATE TABLE "public"."books" (
30
+ "isbn" TEXT NOT NULL,
31
+ "title" TEXT NOT NULL,
32
+ "google_title" TEXT NOT NULL,
33
+ "google_subtitle" TEXT NOT NULL,
34
+ "google_authors" TEXT[],
35
+ "google_description" TEXT NOT NULL,
36
+ "google_img_src" TEXT NOT NULL,
37
+ "google_href" TEXT NOT NULL,
38
+ "markdown" TEXT NOT NULL,
39
+ "rating" INTEGER,
40
+ "tags" TEXT[] DEFAULT ARRAY[]::TEXT[],
41
+ "status" "public"."Status" NOT NULL DEFAULT 'UNEXPORTED',
42
+ "user_id" TEXT NOT NULL,
43
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
44
+ "updated_at" TIMESTAMP(3) NOT NULL,
45
+ "exported_at" TIMESTAMP(3),
46
+
47
+ CONSTRAINT "books_pkey" PRIMARY KEY ("isbn")
48
+ );
49
+
50
+ -- CreateIndex
51
+ CREATE UNIQUE INDEX "books_isbn_key" ON "public"."books"("isbn");
52
+
53
+ -- CreateIndex
54
+ CREATE UNIQUE INDEX "contents_title_key" ON "public"."contents"("title");
@@ -0,0 +1,19 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[isbn,user_id]` on the table `books` will be added. If there are existing duplicate values, this will fail.
5
+ - A unique constraint covering the columns `[title,user_id]` on the table `contents` will be added. If there are existing duplicate values, this will fail.
6
+ - A unique constraint covering the columns `[url,user_id]` on the table `news` will be added. If there are existing duplicate values, this will fail.
7
+
8
+ */
9
+ -- DropIndex
10
+ DROP INDEX "public"."news_url_key";
11
+
12
+ -- CreateIndex
13
+ CREATE UNIQUE INDEX "books_isbn_user_id_key" ON "public"."books"("isbn", "user_id");
14
+
15
+ -- CreateIndex
16
+ CREATE UNIQUE INDEX "contents_title_user_id_key" ON "public"."contents"("title", "user_id");
17
+
18
+ -- CreateIndex
19
+ CREATE UNIQUE INDEX "news_url_user_id_key" ON "public"."news"("url", "user_id");
@@ -0,0 +1,8 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[id,user_id]` on the table `images` will be added. If there are existing duplicate values, this will fail.
5
+
6
+ */
7
+ -- CreateIndex
8
+ CREATE UNIQUE INDEX "images_id_user_id_key" ON "public"."images"("id", "user_id");
@@ -0,0 +1,5 @@
1
+ -- DropIndex
2
+ DROP INDEX "public"."books_isbn_key";
3
+
4
+ -- DropIndex
5
+ DROP INDEX "public"."contents_title_key";
@@ -0,0 +1,27 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The primary key for the `books` table will be changed. If it partially fails, the table could be left without primary key constraint.
5
+ - The primary key for the `contents` table will be changed. If it partially fails, the table could be left without primary key constraint.
6
+ - The primary key for the `news` table will be changed. If it partially fails, the table could be left without primary key constraint.
7
+ - The required column `id` was added to the `books` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
8
+
9
+ */
10
+ -- AlterTable
11
+ ALTER TABLE "public"."books" DROP CONSTRAINT "books_pkey",
12
+ ADD COLUMN "id" TEXT NOT NULL,
13
+ ADD CONSTRAINT "books_pkey" PRIMARY KEY ("id");
14
+
15
+ -- AlterTable
16
+ ALTER TABLE "public"."contents" DROP CONSTRAINT "contents_pkey",
17
+ ALTER COLUMN "id" DROP DEFAULT,
18
+ ALTER COLUMN "id" SET DATA TYPE TEXT,
19
+ ADD CONSTRAINT "contents_pkey" PRIMARY KEY ("id");
20
+ DROP SEQUENCE "contents_id_seq";
21
+
22
+ -- AlterTable
23
+ ALTER TABLE "public"."news" DROP CONSTRAINT "news_pkey",
24
+ ALTER COLUMN "id" DROP DEFAULT,
25
+ ALTER COLUMN "id" SET DATA TYPE TEXT,
26
+ ADD CONSTRAINT "news_pkey" PRIMARY KEY ("id");
27
+ DROP SEQUENCE "news_id_seq";