mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 21:27:20 +01:00
add prisma migration
This commit is contained in:
parent
b415892b7d
commit
6fbd566b29
2 changed files with 67 additions and 13 deletions
47
db/postgresql/migrations/02_add_event_data/migration.sql
Normal file
47
db/postgresql/migrations/02_add_event_data/migration.sql
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "event" ADD COLUMN "event_name" VARCHAR(50);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "event_data" (
|
||||
"event_data_id" SERIAL NOT NULL,
|
||||
"event_id" INTEGER NOT NULL,
|
||||
"event_data" JSONB NOT NULL,
|
||||
|
||||
CONSTRAINT "event_data_pkey" PRIMARY KEY ("event_data_id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "event_data_event_id_key" ON "event_data"("event_id");
|
||||
|
||||
-- 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;
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "account.username_unique" RENAME TO "account_username_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "session.session_uuid_unique" RENAME TO "session_session_uuid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "website.share_id_unique" RENAME TO "website_share_id_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "website.website_uuid_unique" RENAME TO "website_website_uuid_key";
|
||||
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `event_type` on the `event` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `event_value` on the `event` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- Populate event_name
|
||||
update event
|
||||
set "event_name" = event.event_value || '-' || event.event_type;
|
||||
|
||||
--Set event_name not null
|
||||
ALTER TABLE "event" ALTER COLUMN "event_name" SET NOT NULL;
|
||||
|
||||
-- Drop old columns
|
||||
ALTER TABLE "event" DROP COLUMN "event_type",
|
||||
DROP COLUMN "event_value";
|
||||
Loading…
Add table
Add a link
Reference in a new issue