mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
update mysql from planetscale install
This commit is contained in:
parent
cc2be9f47a
commit
318dd7de74
@ -6,10 +6,13 @@ CREATE TABLE `account` (
|
||||
`is_admin` BOOLEAN NOT NULL DEFAULT false,
|
||||
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`account_uuid` VARCHAR(36) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `username`(`username`),
|
||||
UNIQUE INDEX `account_username_key`(`username`),
|
||||
UNIQUE INDEX `account_account_uuid_key`(`account_uuid`),
|
||||
INDEX `account_account_uuid_idx`(`account_uuid`),
|
||||
PRIMARY KEY (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `event` (
|
||||
@ -18,14 +21,26 @@ CREATE TABLE `event` (
|
||||
`session_id` INTEGER UNSIGNED NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`url` VARCHAR(500) NOT NULL,
|
||||
`event_type` VARCHAR(50) NOT NULL,
|
||||
`event_value` VARCHAR(50) NOT NULL,
|
||||
`event_name` VARCHAR(50) NOT NULL,
|
||||
`event_uuid` VARCHAR(36) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `event_event_uuid_key`(`event_uuid`),
|
||||
INDEX `event_created_at_idx`(`created_at`),
|
||||
INDEX `event_session_id_idx`(`session_id`),
|
||||
INDEX `event_website_id_idx`(`website_id`),
|
||||
INDEX `event_event_uuid_idx`(`event_uuid`),
|
||||
PRIMARY KEY (`event_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `event_data` (
|
||||
`event_data_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`event_id` INTEGER UNSIGNED NOT NULL,
|
||||
`event_data` JSON NOT NULL,
|
||||
|
||||
UNIQUE INDEX `event_data_event_id_key`(`event_id`),
|
||||
PRIMARY KEY (`event_data_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `pageview` (
|
||||
@ -42,7 +57,7 @@ CREATE TABLE `pageview` (
|
||||
INDEX `pageview_website_id_idx`(`website_id`),
|
||||
INDEX `pageview_website_id_session_id_created_at_idx`(`website_id`, `session_id`, `created_at`),
|
||||
PRIMARY KEY (`view_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `session` (
|
||||
@ -58,11 +73,12 @@ CREATE TABLE `session` (
|
||||
`language` VARCHAR(35) NULL,
|
||||
`country` CHAR(2) NULL,
|
||||
|
||||
UNIQUE INDEX `session_uuid`(`session_uuid`),
|
||||
UNIQUE INDEX `session_session_uuid_key`(`session_uuid`),
|
||||
INDEX `session_created_at_idx`(`created_at`),
|
||||
INDEX `session_website_id_idx`(`website_id`),
|
||||
INDEX `session_session_uuid_idx`(`session_uuid`),
|
||||
PRIMARY KEY (`session_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `website` (
|
||||
@ -74,29 +90,12 @@ CREATE TABLE `website` (
|
||||
`share_id` VARCHAR(64) NULL,
|
||||
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
|
||||
UNIQUE INDEX `website_uuid`(`website_uuid`),
|
||||
UNIQUE INDEX `share_id`(`share_id`),
|
||||
UNIQUE INDEX `website_website_uuid_key`(`website_uuid`),
|
||||
UNIQUE INDEX `website_share_id_key`(`share_id`),
|
||||
INDEX `website_user_id_idx`(`user_id`),
|
||||
INDEX `website_website_uuid_idx`(`website_uuid`),
|
||||
PRIMARY KEY (`website_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- 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 `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;
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateAdminUser
|
||||
INSERT INTO account (username, password, is_admin) values ('admin', '$2b$10$BUli0c.muyCW1ErNJc3jL.vFRFtFJWrT8/GcR4A.sUdCznaXiqFXa', true);
|
||||
INSERT INTO account (username, password, is_admin, account_uuid) values ('admin', '$2b$10$BUli0c.muyCW1ErNJc3jL.vFRFtFJWrT8/GcR4A.sUdCznaXiqFXa', true, uuid());
|
Loading…
Reference in New Issue
Block a user