Make initial migration usable
This commit is contained in:
parent
00d2b02fb2
commit
a9ce96a95c
@ -42,3 +42,7 @@ XFF_DEPTH=1
|
||||
|
||||
# Run database migrations automatically on startup
|
||||
AUTO_MIGRATE=true
|
||||
|
||||
# hCaptcha keys, leave empty if not using it
|
||||
PUBLIC_HCAPTCHA_KEY=
|
||||
HCAPTCHA_SECRET=
|
||||
|
@ -1,4 +1,3 @@
|
||||
/*
|
||||
CREATE TABLE `audit_log` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
`action` text NOT NULL,
|
||||
@ -8,7 +7,7 @@ CREATE TABLE `audit_log` (
|
||||
`flagged` tinyint NOT NULL DEFAULT 0,
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`actorId` int(11) DEFAULT 'NULL'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `document` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -18,7 +17,7 @@ CREATE TABLE `document` (
|
||||
`authorId` int(11) DEFAULT 'NULL',
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`updated_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `o_auth2_client` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -35,7 +34,7 @@ CREATE TABLE `o_auth2_client` (
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`updated_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
CONSTRAINT `IDX_e9d16c213910ad57bd05e97b42` UNIQUE(`client_id`)
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `o_auth2_client_authorization` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -44,7 +43,7 @@ CREATE TABLE `o_auth2_client_authorization` (
|
||||
`clientId` int(11) DEFAULT 'NULL',
|
||||
`userId` int(11) DEFAULT 'NULL',
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `o_auth2_client_url` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -53,7 +52,7 @@ CREATE TABLE `o_auth2_client_url` (
|
||||
`created_at` timestamp(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`updated_at` timestamp(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`clientId` int(11) DEFAULT 'NULL'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `o_auth2_token` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -67,12 +66,12 @@ CREATE TABLE `o_auth2_token` (
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`updated_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`pcke` text DEFAULT 'NULL'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `privilege` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
`name` text NOT NULL
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `upload` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -82,7 +81,7 @@ CREATE TABLE `upload` (
|
||||
`uploaderId` int(11) DEFAULT 'NULL',
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)',
|
||||
`updated_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -99,12 +98,12 @@ CREATE TABLE `user` (
|
||||
CONSTRAINT `IDX_a95e949168be7b7ece1a2382fe` UNIQUE(`uuid`),
|
||||
CONSTRAINT `IDX_78a916df40e02a9deb1c4b75ed` UNIQUE(`username`),
|
||||
CONSTRAINT `IDX_e12875dfb3b1d92d7d7c5377e2` UNIQUE(`email`)
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `user_privileges_privilege` (
|
||||
`userId` int(11) NOT NULL,
|
||||
`privilegeId` int(11) NOT NULL
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
CREATE TABLE `user_token` (
|
||||
`id` int(11) AUTO_INCREMENT NOT NULL,
|
||||
@ -114,22 +113,21 @@ CREATE TABLE `user_token` (
|
||||
`userId` int(11) DEFAULT 'NULL',
|
||||
`nonce` text DEFAULT 'NULL',
|
||||
`created_at` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)'
|
||||
);
|
||||
);--> statement-breakpoint
|
||||
|
||||
ALTER TABLE `audit_log` ADD CONSTRAINT `FK_cb6aa6f6fd56f08eafb60316225` FOREIGN KEY (`actorId`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
ALTER TABLE `document` ADD CONSTRAINT `FK_6a2eb13cadfc503989cbe367572` FOREIGN KEY (`authorId`) REFERENCES `user`(`id`) ON DELETE no action ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_client` ADD CONSTRAINT `FK_4a6c878506b872e85b3d07f6252` FOREIGN KEY (`ownerId`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_client` ADD CONSTRAINT `FK_e8d65b1eec13474e493420517d7` FOREIGN KEY (`pictureId`) REFERENCES `upload`(`id`) ON DELETE set null ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_client_authorization` ADD CONSTRAINT `FK_8227110f58510b7233f3db90cfb` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_client_authorization` ADD CONSTRAINT `FK_9ca9ebb654e7ce71954d5fdb281` FOREIGN KEY (`clientId`) REFERENCES `o_auth2_client`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_client_url` ADD CONSTRAINT `FK_aca59c7bdd65987487eea98d00f` FOREIGN KEY (`clientId`) REFERENCES `o_auth2_client`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_token` ADD CONSTRAINT `FK_3ecb760b321ef9bbab635f05b45` FOREIGN KEY (`clientId`) REFERENCES `o_auth2_client`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
ALTER TABLE `o_auth2_token` ADD CONSTRAINT `FK_81ffb9b8d672cf3af1af9e789f3` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
ALTER TABLE `upload` ADD CONSTRAINT `FK_7b8d52838a953b188255682597b` FOREIGN KEY (`uploaderId`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE cascade;
|
||||
ALTER TABLE `user` ADD CONSTRAINT `FK_7478a15985dbfa32ed5fc77a7a1` FOREIGN KEY (`pictureId`) REFERENCES `upload`(`id`) ON DELETE set null ON UPDATE cascade;
|
||||
ALTER TABLE `user_privileges_privilege` ADD CONSTRAINT `FK_0664a7ff494a1859a09014c0f17` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE cascade;
|
||||
ALTER TABLE `user_privileges_privilege` ADD CONSTRAINT `FK_e71171f4ed20bc8564a1819d0b7` FOREIGN KEY (`privilegeId`) REFERENCES `privilege`(`id`) ON DELETE cascade ON UPDATE cascade;
|
||||
ALTER TABLE `user_token` ADD CONSTRAINT `FK_d37db50eecdf9b8ce4eedd2f918` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;
|
||||
CREATE INDEX `IDX_0664a7ff494a1859a09014c0f1` ON `user_privileges_privilege` (`userId`);
|
||||
ALTER TABLE `audit_log` ADD CONSTRAINT `FK_cb6aa6f6fd56f08eafb60316225` FOREIGN KEY (`actorId`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `document` ADD CONSTRAINT `FK_6a2eb13cadfc503989cbe367572` FOREIGN KEY (`authorId`) REFERENCES `user`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_client` ADD CONSTRAINT `FK_4a6c878506b872e85b3d07f6252` FOREIGN KEY (`ownerId`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_client` ADD CONSTRAINT `FK_e8d65b1eec13474e493420517d7` FOREIGN KEY (`pictureId`) REFERENCES `upload`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_client_authorization` ADD CONSTRAINT `FK_8227110f58510b7233f3db90cfb` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_client_authorization` ADD CONSTRAINT `FK_9ca9ebb654e7ce71954d5fdb281` FOREIGN KEY (`clientId`) REFERENCES `o_auth2_client`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_client_url` ADD CONSTRAINT `FK_aca59c7bdd65987487eea98d00f` FOREIGN KEY (`clientId`) REFERENCES `o_auth2_client`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_token` ADD CONSTRAINT `FK_3ecb760b321ef9bbab635f05b45` FOREIGN KEY (`clientId`) REFERENCES `o_auth2_client`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_token` ADD CONSTRAINT `FK_81ffb9b8d672cf3af1af9e789f3` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE `upload` ADD CONSTRAINT `FK_7b8d52838a953b188255682597b` FOREIGN KEY (`uploaderId`) REFERENCES `user`(`id`) ON DELETE set null ON UPDATE cascade;--> statement-breakpoint
|
||||
ALTER TABLE `user` ADD CONSTRAINT `FK_7478a15985dbfa32ed5fc77a7a1` FOREIGN KEY (`pictureId`) REFERENCES `upload`(`id`) ON DELETE set null ON UPDATE cascade;--> statement-breakpoint
|
||||
ALTER TABLE `user_privileges_privilege` ADD CONSTRAINT `FK_0664a7ff494a1859a09014c0f17` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
|
||||
ALTER TABLE `user_privileges_privilege` ADD CONSTRAINT `FK_e71171f4ed20bc8564a1819d0b7` FOREIGN KEY (`privilegeId`) REFERENCES `privilege`(`id`) ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
|
||||
ALTER TABLE `user_token` ADD CONSTRAINT `FK_d37db50eecdf9b8ce4eedd2f918` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX `IDX_0664a7ff494a1859a09014c0f1` ON `user_privileges_privilege` (`userId`);--> statement-breakpoint
|
||||
CREATE INDEX `IDX_e71171f4ed20bc8564a1819d0b` ON `user_privileges_privilege` (`privilegeId`);
|
||||
*/
|
||||
|
@ -6,7 +6,6 @@ CREATE TABLE `o_auth2_client_manager` (
|
||||
`created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
|
||||
`updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6)
|
||||
);--> statement-breakpoint
|
||||
DROP TABLE `migrations`;--> statement-breakpoint
|
||||
ALTER TABLE `audit_log` DROP FOREIGN KEY `FK_cb6aa6f6fd56f08eafb60316225`;--> statement-breakpoint
|
||||
ALTER TABLE `document` DROP FOREIGN KEY `FK_6a2eb13cadfc503989cbe367572`;--> statement-breakpoint
|
||||
ALTER TABLE `o_auth2_client` DROP FOREIGN KEY `FK_4a6c878506b872e85b3d07f6252`;--> statement-breakpoint
|
||||
|
@ -164,36 +164,6 @@
|
||||
},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"migrations": {
|
||||
"name": "migrations",
|
||||
"columns": {
|
||||
"id": {
|
||||
"autoincrement": true,
|
||||
"name": "id",
|
||||
"type": "int(11)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"timestamp": {
|
||||
"autoincrement": false,
|
||||
"name": "timestamp",
|
||||
"type": "bigint(20)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"autoincrement": false,
|
||||
"name": "name",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"o_auth2_client": {
|
||||
"name": "o_auth2_client",
|
||||
"columns": {
|
||||
@ -982,4 +952,4 @@
|
||||
"internal": {
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user