-- Current sql file was generated after introspecting the database
-- If you want to run this migration please uncomment this code before executing migrations
/*
CREATE TABLE `sys_dict` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`version` int NOT NULL DEFAULT 0,
	`pid` bigint NOT NULL,
	`module` tinyint,
	`dict_key` varchar(255),
	`value` varchar(255),
	`description` varchar(255),
	`sort` int NOT NULL DEFAULT 0,
	`status` int NOT NULL,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_dict_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_dict_key` UNIQUE(`dict_key`,`pid`)
);
--> statement-breakpoint
CREATE TABLE `sys_organization` (
	`org_id` bigint AUTO_INCREMENT NOT NULL,
	`pid` bigint NOT NULL DEFAULT 0,
	`org_name` varchar(255),
	`org_code` varchar(128),
	`org_type` int NOT NULL,
	`description` varchar(255),
	`sort` int NOT NULL DEFAULT 0,
	`status` int NOT NULL,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_organization_org_id` PRIMARY KEY(`org_id`),
	CONSTRAINT `uniq_org_code` UNIQUE(`org_code`,`pid`),
	CONSTRAINT `uniq_org_name` UNIQUE(`org_name`,`pid`)
);
--> statement-breakpoint
CREATE TABLE `sys_organization_manager` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`version` int NOT NULL DEFAULT 0,
	`org_id` bigint NOT NULL,
	`user_id` bigint NOT NULL,
	`rank` int NOT NULL,
	`description` varchar(255),
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_organization_manager_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_org_user` UNIQUE(`org_id`,`user_id`)
);
--> statement-breakpoint
CREATE TABLE `sys_permission` (
	`perm_id` bigint AUTO_INCREMENT NOT NULL,
	`pid` bigint NOT NULL DEFAULT 0,
	`perm_name` varchar(255) NOT NULL,
	`perm_key` varchar(255) NOT NULL,
	`url` varchar(255),
	`avatar_url` varchar(255),
	`description` varchar(255),
	`perm_type` int NOT NULL,
	`is_visible` int NOT NULL DEFAULT 0,
	`version` int NOT NULL DEFAULT 0,
	`sort` int NOT NULL DEFAULT 0,
	`status` int NOT NULL,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_permission_perm_id` PRIMARY KEY(`perm_id`),
	CONSTRAINT `uniq_pid_name` UNIQUE(`perm_name`,`pid`),
	CONSTRAINT `uniq_perm_key` UNIQUE(`perm_key`)
);
--> statement-breakpoint
CREATE TABLE `sys_re_role_permission` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`role_id` bigint NOT NULL,
	`perm_id` bigint NOT NULL,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_re_role_permission_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_perm_role` UNIQUE(`role_id`,`perm_id`)
);
--> statement-breakpoint
CREATE TABLE `sys_re_user_organization` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`user_id` bigint NOT NULL,
	`org_id` bigint NOT NULL,
	`version` int NOT NULL DEFAULT 0,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_re_user_organization_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_user_org` UNIQUE(`user_id`,`org_id`)
);
--> statement-breakpoint
CREATE TABLE `sys_re_user_role` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`user_id` bigint NOT NULL,
	`role_id` bigint NOT NULL,
	`version` int NOT NULL DEFAULT 0,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_re_user_role_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_user_role` UNIQUE(`user_id`,`role_id`)
);
--> statement-breakpoint
CREATE TABLE `sys_role` (
	`role_id` bigint AUTO_INCREMENT NOT NULL,
	`pid` bigint NOT NULL,
	`role_name` varchar(255) NOT NULL,
	`role_key` varchar(255) NOT NULL,
	`description` varchar(255),
	`status` int NOT NULL,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_role_role_id` PRIMARY KEY(`role_id`),
	CONSTRAINT `uniq_role_pid` UNIQUE(`role_name`,`pid`)
);
--> statement-breakpoint
CREATE TABLE `sys_user` (
	`user_id` bigint NOT NULL,
	`pid` bigint NOT NULL,
	`username` varchar(255) NOT NULL,
	`email` varchar(255) NOT NULL,
	`phone` varchar(255),
	`avatar_url` varchar(255),
	`user_type` tinyint,
	`status` tinyint NOT NULL DEFAULT 0,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_user_user_id` PRIMARY KEY(`user_id`),
	CONSTRAINT `uniq_username` UNIQUE(`username`),
	CONSTRAINT `uniq_email` UNIQUE(`email`)
);
--> statement-breakpoint
CREATE TABLE `sys_user_auth` (
	`user_id` bigint NOT NULL,
	`password_hash` varchar(255) NOT NULL,
	`password_modified` datetime NOT NULL,
	`password_expire` datetime,
	CONSTRAINT `sys_user_auth_user_id` PRIMARY KEY(`user_id`)
);
--> statement-breakpoint
CREATE TABLE `sys_user_auth_history` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`user_id` bigint NOT NULL,
	`password_hash` varchar(255) NOT NULL,
	`modified_at` varchar(255) NOT NULL,
	CONSTRAINT `sys_user_auth_history_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `sys_user_field_definition` (
	`field_id` bigint AUTO_INCREMENT NOT NULL,
	`version` int NOT NULL DEFAULT 0,
	`field_name` varchar(255) NOT NULL,
	`field_key` varchar(255) NOT NULL,
	`field_type` tinyint NOT NULL,
	`dict_module` int,
	`is_required` tinyint NOT NULL DEFAULT 0,
	`limit` int,
	`description` varchar(255),
	`default_value` varchar(255),
	`default_options` varchar(255),
	`sort` int NOT NULL DEFAULT 0,
	`status` int NOT NULL,
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_user_field_definition_field_id` PRIMARY KEY(`field_id`),
	CONSTRAINT `uniq_field_name` UNIQUE(`field_name`),
	CONSTRAINT `uniq_field_key` UNIQUE(`field_key`)
);
--> statement-breakpoint
CREATE TABLE `sys_user_field_value` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`user_id` bigint NOT NULL,
	`field_id` int NOT NULL,
	`value` varchar(4096),
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_user_field_value_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_user_field` UNIQUE(`user_id`,`field_id`)
);
--> statement-breakpoint
CREATE TABLE `sys_user_profile` (
	`id` bigint AUTO_INCREMENT NOT NULL,
	`version` int NOT NULL DEFAULT 0,
	`name` varchar(32) NOT NULL,
	`profile_key` varchar(255) NOT NULL,
	`description` varchar(255),
	`content` varchar(255),
	`created_by` bigint NOT NULL,
	`updated_by` bigint NOT NULL,
	`created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	`updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
	CONSTRAINT `sys_user_profile_id` PRIMARY KEY(`id`),
	CONSTRAINT `uniq_name` UNIQUE(`name`),
	CONSTRAINT `uniq_profile_key` UNIQUE(`profile_key`)
);

*/