Merge pull request #1440 from umami-software/brian/um-30-bigint

big int
This commit is contained in:
Mike Cao 2022-08-22 01:47:58 -05:00 committed by GitHub
commit 864acda388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 235 additions and 28 deletions

View File

@ -0,0 +1,106 @@
/*
Warnings:
- The primary key for the `account` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to alter the column `user_id` on the `account` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- The primary key for the `event` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to alter the column `event_id` on the `event` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to alter the column `website_id` on the `event` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to alter the column `session_id` on the `event` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- The primary key for the `event_data` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to alter the column `event_data_id` on the `event_data` table. The data in that column could be lost. The data in that column will be cast from `Int` to `UnsignedBigInt`.
- You are about to alter the column `event_id` on the `event_data` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- The primary key for the `pageview` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to alter the column `view_id` on the `pageview` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to alter the column `website_id` on the `pageview` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to alter the column `session_id` on the `pageview` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- The primary key for the `session` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to alter the column `session_id` on the `session` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to alter the column `website_id` on the `session` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- The primary key for the `website` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to alter the column `website_id` on the `website` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to alter the column `user_id` on the `website` table. The data in that column could be lost. The data in that column will be cast from `UnsignedInt` to `UnsignedBigInt`.
- You are about to drop the `_event_old` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE `event` DROP FOREIGN KEY `event_ibfk_1`;
-- DropForeignKey
ALTER TABLE `event` DROP FOREIGN KEY `event_ibfk_2`;
-- DropForeignKey
ALTER TABLE `event_data` DROP FOREIGN KEY `event_data_event_id_fkey`;
-- DropForeignKey
ALTER TABLE `pageview` DROP FOREIGN KEY `pageview_ibfk_1`;
-- DropForeignKey
ALTER TABLE `pageview` DROP FOREIGN KEY `pageview_ibfk_2`;
-- DropForeignKey
ALTER TABLE `session` DROP FOREIGN KEY `session_ibfk_1`;
-- DropForeignKey
ALTER TABLE `website` DROP FOREIGN KEY `website_ibfk_1`;
-- AlterTable
ALTER TABLE `account` DROP PRIMARY KEY,
MODIFY `user_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY (`user_id`);
-- AlterTable
ALTER TABLE `event` DROP PRIMARY KEY,
MODIFY `event_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
MODIFY `website_id` BIGINT UNSIGNED NOT NULL,
MODIFY `session_id` BIGINT UNSIGNED NOT NULL,
ADD PRIMARY KEY (`event_id`);
-- AlterTable
ALTER TABLE `event_data` DROP PRIMARY KEY,
MODIFY `event_data_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
MODIFY `event_id` BIGINT UNSIGNED NOT NULL,
ADD PRIMARY KEY (`event_data_id`);
-- AlterTable
ALTER TABLE `pageview` DROP PRIMARY KEY,
MODIFY `view_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
MODIFY `website_id` BIGINT UNSIGNED NOT NULL,
MODIFY `session_id` BIGINT UNSIGNED NOT NULL,
ADD PRIMARY KEY (`view_id`);
-- AlterTable
ALTER TABLE `session` DROP PRIMARY KEY,
MODIFY `session_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
MODIFY `website_id` BIGINT UNSIGNED NOT NULL,
ADD PRIMARY KEY (`session_id`);
-- AlterTable
ALTER TABLE `website` DROP PRIMARY KEY,
MODIFY `website_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
MODIFY `user_id` BIGINT UNSIGNED NOT NULL,
ADD PRIMARY KEY (`website_id`);
-- DropTable
DROP TABLE `_event_old`;
-- AddForeignKey
ALTER TABLE `event` ADD CONSTRAINT `event_ibfk_2` FOREIGN KEY (`session_id`) REFERENCES `session`(`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE `event` ADD CONSTRAINT `event_ibfk_1` FOREIGN KEY (`website_id`) REFERENCES `website`(`website_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE `event_data` ADD CONSTRAINT `event_data_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `event`(`event_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `pageview` ADD CONSTRAINT `pageview_ibfk_2` FOREIGN KEY (`session_id`) REFERENCES `session`(`session_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE `pageview` ADD CONSTRAINT `pageview_ibfk_1` FOREIGN KEY (`website_id`) REFERENCES `website`(`website_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE `session` ADD CONSTRAINT `session_ibfk_1` FOREIGN KEY (`website_id`) REFERENCES `website`(`website_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
-- AddForeignKey
ALTER TABLE `website` ADD CONSTRAINT `website_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`(`user_id`) ON DELETE CASCADE ON UPDATE NO ACTION;

View File

@ -8,7 +8,7 @@ datasource db {
}
model account {
user_id Int @id @default(autoincrement()) @db.UnsignedInt
user_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
username String @unique() @db.VarChar(255)
password String @db.VarChar(60)
is_admin Boolean @default(false)
@ -18,9 +18,9 @@ model account {
}
model event {
event_id Int @id @default(autoincrement()) @db.UnsignedInt
website_id Int @db.UnsignedInt
session_id Int @db.UnsignedInt
event_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
website_id BigInt @db.UnsignedBigInt
session_id BigInt @db.UnsignedBigInt
created_at DateTime? @default(now()) @db.Timestamp(0)
url String @db.VarChar(500)
event_name String @db.VarChar(50)
@ -34,16 +34,16 @@ model event {
}
model event_data {
event_data_id Int @id @default(autoincrement())
event_id Int @unique @db.UnsignedInt
event_data_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
event_id BigInt @unique @db.UnsignedBigInt
event_data Json
event event @relation(fields: [event_id], references: [event_id])
event event @relation(fields: [event_id], references: [event_id])
}
model pageview {
view_id Int @id @default(autoincrement()) @db.UnsignedInt
website_id Int @db.UnsignedInt
session_id Int @db.UnsignedInt
view_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
website_id BigInt @db.UnsignedBigInt
session_id BigInt @db.UnsignedBigInt
created_at DateTime? @default(now()) @db.Timestamp(0)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
@ -58,9 +58,9 @@ model pageview {
}
model session {
session_id Int @id @default(autoincrement()) @db.UnsignedInt
session_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
session_uuid String @unique() @db.VarChar(36)
website_id Int @db.UnsignedInt
website_id BigInt @db.UnsignedBigInt
created_at DateTime? @default(now()) @db.Timestamp(0)
hostname String? @db.VarChar(100)
browser String? @db.VarChar(20)
@ -78,9 +78,9 @@ model session {
}
model website {
website_id Int @id @default(autoincrement()) @db.UnsignedInt
website_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
website_uuid String @unique() @db.VarChar(36)
user_id Int @db.UnsignedInt
user_id BigInt @db.UnsignedBigInt
name String @db.VarChar(100)
domain String? @db.VarChar(500)
share_id String? @unique() @db.VarChar(64)

View File

@ -0,0 +1,101 @@
/*
Warnings:
- The primary key for the `account` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `event` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `event_data` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `pageview` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `session` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `website` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the `_event_old` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "event" DROP CONSTRAINT "event_session_id_fkey";
-- DropForeignKey
ALTER TABLE "event" DROP CONSTRAINT "event_website_id_fkey";
-- DropForeignKey
ALTER TABLE "event_data" DROP CONSTRAINT "event_data_event_id_fkey";
-- DropForeignKey
ALTER TABLE "pageview" DROP CONSTRAINT "pageview_session_id_fkey";
-- DropForeignKey
ALTER TABLE "pageview" DROP CONSTRAINT "pageview_website_id_fkey";
-- DropForeignKey
ALTER TABLE "session" DROP CONSTRAINT "session_website_id_fkey";
-- DropForeignKey
ALTER TABLE "website" DROP CONSTRAINT "website_user_id_fkey";
-- AlterTable
ALTER TABLE "account" DROP CONSTRAINT "account_pkey",
ALTER COLUMN "user_id" SET DATA TYPE BIGINT,
ADD CONSTRAINT "account_pkey" PRIMARY KEY ("user_id");
-- AlterTable
ALTER TABLE "event" DROP CONSTRAINT "event_pkey",
ALTER COLUMN "event_id" SET DATA TYPE BIGINT,
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
ALTER COLUMN "session_id" SET DATA TYPE BIGINT,
ADD CONSTRAINT "event_pkey" PRIMARY KEY ("event_id");
-- AlterTable
ALTER TABLE "event_data" DROP CONSTRAINT "event_data_pkey",
ALTER COLUMN "event_data_id" SET DATA TYPE BIGINT,
ALTER COLUMN "event_id" SET DATA TYPE BIGINT,
ADD CONSTRAINT "event_data_pkey" PRIMARY KEY ("event_data_id");
-- AlterTable
ALTER TABLE "pageview" DROP CONSTRAINT "pageview_pkey",
ALTER COLUMN "view_id" SET DATA TYPE BIGINT,
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
ALTER COLUMN "session_id" SET DATA TYPE BIGINT,
ADD CONSTRAINT "pageview_pkey" PRIMARY KEY ("view_id");
-- AlterTable
ALTER TABLE "session" DROP CONSTRAINT "session_pkey",
ALTER COLUMN "session_id" SET DATA TYPE BIGINT,
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
ADD CONSTRAINT "session_pkey" PRIMARY KEY ("session_id");
-- AlterTable
ALTER TABLE "website" DROP CONSTRAINT "website_pkey",
ALTER COLUMN "website_id" SET DATA TYPE BIGINT,
ALTER COLUMN "user_id" SET DATA TYPE BIGINT,
ADD CONSTRAINT "website_pkey" PRIMARY KEY ("website_id");
-- Dev: Alter Sequence
ALTER SEQUENCE account_user_id_seq AS BIGINT;
ALTER SEQUENCE event_data_event_data_id_seq AS BIGINT;
ALTER SEQUENCE event_event_id_seq AS BIGINT;
ALTER SEQUENCE pageview_view_id_seq AS BIGINT;
ALTER SEQUENCE session_session_id_seq AS BIGINT;
ALTER SEQUENCE website_website_id_seq AS BIGINT;
-- DropTable
DROP TABLE "_event_old";
-- AddForeignKey
ALTER TABLE "event" ADD CONSTRAINT "event_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "session"("session_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "event" ADD CONSTRAINT "event_website_id_fkey" FOREIGN KEY ("website_id") REFERENCES "website"("website_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "event_data" ADD CONSTRAINT "event_data_event_id_fkey" FOREIGN KEY ("event_id") REFERENCES "event"("event_id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pageview" ADD CONSTRAINT "pageview_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "session"("session_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pageview" ADD CONSTRAINT "pageview_website_id_fkey" FOREIGN KEY ("website_id") REFERENCES "website"("website_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "session" ADD CONSTRAINT "session_website_id_fkey" FOREIGN KEY ("website_id") REFERENCES "website"("website_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "website" ADD CONSTRAINT "website_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "account"("user_id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -8,7 +8,7 @@ datasource db {
}
model account {
user_id Int @id @default(autoincrement())
user_id BigInt @id @default(autoincrement())
username String @unique @db.VarChar(255)
password String @db.VarChar(60)
is_admin Boolean @default(false)
@ -18,9 +18,9 @@ model account {
}
model event {
event_id Int @id @default(autoincrement())
website_id Int
session_id Int
event_id BigInt @id @default(autoincrement())
website_id BigInt
session_id BigInt
created_at DateTime? @default(now()) @db.Timestamptz(6)
url String @db.VarChar(500)
event_name String @db.VarChar(50)
@ -34,16 +34,16 @@ model event {
}
model event_data {
event_data_id Int @id @default(autoincrement())
event_id Int @unique
event_data_id BigInt @id @default(autoincrement())
event_id BigInt @unique
event_data Json
event event @relation(fields: [event_id], references: [event_id])
event event @relation(fields: [event_id], references: [event_id])
}
model pageview {
view_id Int @id @default(autoincrement())
website_id Int
session_id Int
view_id BigInt @id @default(autoincrement())
website_id BigInt
session_id BigInt
created_at DateTime? @default(now()) @db.Timestamptz(6)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
@ -58,9 +58,9 @@ model pageview {
}
model session {
session_id Int @id @default(autoincrement())
session_id BigInt @id @default(autoincrement())
session_uuid String @unique @db.Uuid
website_id Int
website_id BigInt
created_at DateTime? @default(now()) @db.Timestamptz(6)
hostname String? @db.VarChar(100)
browser String? @db.VarChar(20)
@ -78,9 +78,9 @@ model session {
}
model website {
website_id Int @id @default(autoincrement())
website_id BigInt @id @default(autoincrement())
website_uuid String @unique @db.Uuid
user_id Int
user_id BigInt
name String @db.VarChar(100)
domain String? @db.VarChar(500)
share_id String? @unique @db.VarChar(64)