@@ -0,0 +1,206 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
create table `outbox` (
|
||||
`id` char(36) primary key,
|
||||
`org_id` char(36) not null,
|
||||
`name` text not null,
|
||||
`payload` json not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`attempts` integer not null,
|
||||
`published_at` datetime(6),
|
||||
`last_error` text,
|
||||
`deferrals` integer not null default 0,
|
||||
`deferred_since` datetime(6),
|
||||
`deferred_until` datetime(6)
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
create index `outbox_pending_idx` on `outbox` (`created_at`);
|
||||
|
||||
create table `idempotency_keys` (
|
||||
`org_id` char(36) not null,
|
||||
-- Not null, with the zero uuid where a scope has no workspace or project: a primary key
|
||||
-- ignores a row whose column is NULL, and the key would stop being unique.
|
||||
`workspace_id` char(36) not null,
|
||||
`project_id` char(36) not null,
|
||||
`procedure` varchar(255) not null,
|
||||
`key` varchar(255) not null,
|
||||
-- The response may itself be the JSON value null, so "finished" is a column of its own
|
||||
-- rather than a non-null response. Null while the transaction that claimed this key is
|
||||
-- running; a second caller's insert blocks on the key until that transaction ends.
|
||||
`response` json,
|
||||
`completed_at` datetime(6),
|
||||
`created_at` datetime(6) not null,
|
||||
primary key (`org_id`, `workspace_id`, `project_id`, `procedure`, `key`)
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
create table `auth_api_keys` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`name` text not null,
|
||||
`token_hash` text not null,
|
||||
`prefix` text not null,
|
||||
`user_id` char(36) not null,
|
||||
`expires_at` text,
|
||||
`revoked_at` text
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `auth_api_keys` add constraint `auth_api_keys_org_id_token_hash_key` unique (`org_id`, `token_hash`);
|
||||
|
||||
create index `auth_api_keys_org_id_user_id_idx` on `auth_api_keys` (`org_id`, `user_id`);
|
||||
|
||||
create index `auth_api_keys_org_id_prefix_idx` on `auth_api_keys` (`org_id`, `prefix`(191));
|
||||
|
||||
create table `auth_sessions` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`user_id` char(36) not null,
|
||||
`issuer` text not null,
|
||||
`subject` text not null,
|
||||
`handle_hash` text not null,
|
||||
`tokens` text not null,
|
||||
`access_token_expires_at` text not null,
|
||||
`last_seen_at` text not null,
|
||||
`absolute_expires_at` text not null,
|
||||
`revoked_at` text
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `auth_sessions` add constraint `auth_sessions_handle_hash_key` unique (`handle_hash`);
|
||||
|
||||
create index `auth_sessions_user_id_idx` on `auth_sessions` (`user_id`);
|
||||
|
||||
create index `auth_sessions_absolute_expires_at_idx` on `auth_sessions` (`absolute_expires_at`(191));
|
||||
|
||||
create table `extensions` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`subject_type` text not null,
|
||||
`subject_id` char(36) not null,
|
||||
`namespace` text not null,
|
||||
`payload` json not null,
|
||||
`payload_version` integer not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `extensions` add constraint `extensions_org_id_subject_type_subject_id_namespace_key` unique (`org_id`, `subject_type`, `subject_id`, `namespace`);
|
||||
|
||||
create index `extensions_org_id_namespace_idx` on `extensions` (`org_id`, `namespace`(191));
|
||||
|
||||
create table `invitations` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`email` text not null,
|
||||
`role` text not null,
|
||||
`workspace_id` char(36),
|
||||
`workspace_role` text,
|
||||
`token_hash` text not null,
|
||||
`expires_at` text not null,
|
||||
`accepted_at` text,
|
||||
`invited_by` char(36) not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `invitations` add constraint `invitations_org_id_token_hash_key` unique (`org_id`, `token_hash`);
|
||||
|
||||
create index `invitations_org_id_email_idx` on `invitations` (`org_id`, `email`(191));
|
||||
|
||||
create index `invitations_org_id_accepted_at_idx` on `invitations` (`org_id`, `accepted_at`(191));
|
||||
|
||||
create table `org_memberships` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`user_id` char(36) not null,
|
||||
`role` text not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `org_memberships` add constraint `org_memberships_org_id_user_id_key` unique (`org_id`, `user_id`);
|
||||
|
||||
create index `org_memberships_org_id_role_idx` on `org_memberships` (`org_id`, `role`(191));
|
||||
|
||||
create table `organizations` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`slug` text not null,
|
||||
`name` text not null,
|
||||
`status` text not null,
|
||||
`settings` json not null,
|
||||
`branding` json
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `organizations` add constraint `organizations_slug_key` unique (`slug`);
|
||||
|
||||
create index `organizations_status_idx` on `organizations` (`status`(191));
|
||||
|
||||
create table `projects` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`workspace_id` char(36) not null,
|
||||
`slug` text not null,
|
||||
`name` text not null,
|
||||
`module_key` text not null,
|
||||
`archived_at` text
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `projects` add constraint `projects_org_id_workspace_id_slug_key` unique (`org_id`, `workspace_id`, `slug`);
|
||||
|
||||
create index `projects_org_id_workspace_id_archived_at_idx` on `projects` (`org_id`, `workspace_id`, `archived_at`(191));
|
||||
|
||||
create table `users` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`issuer` text not null,
|
||||
`subject` text not null,
|
||||
`email` text not null,
|
||||
`display_name` text not null,
|
||||
`locale` text not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `users` add constraint `users_issuer_subject_key` unique (`issuer`, `subject`);
|
||||
|
||||
create index `users_email_idx` on `users` (`email`(191));
|
||||
|
||||
create table `workspace_memberships` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`workspace_id` char(36) not null,
|
||||
`user_id` char(36) not null,
|
||||
`role` text not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `workspace_memberships` add constraint `workspace_memberships_org_id_workspace_id_user_id_key` unique (`org_id`, `workspace_id`, `user_id`);
|
||||
|
||||
create index `workspace_memberships_org_id_user_id_idx` on `workspace_memberships` (`org_id`, `user_id`);
|
||||
|
||||
create table `workspaces` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`slug` text not null,
|
||||
`name` text not null,
|
||||
`is_default` boolean not null,
|
||||
`visibility` text not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `workspaces` add constraint `workspaces_org_id_slug_key` unique (`org_id`, `slug`);
|
||||
@@ -0,0 +1,28 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
create table `files_file` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`workspace_id` char(36) not null,
|
||||
`project_id` char(36) not null,
|
||||
`status` text not null,
|
||||
`storage_key` text not null,
|
||||
`filename` text not null,
|
||||
`content_type` text not null,
|
||||
`size` integer,
|
||||
`sha256` text,
|
||||
`uploaded_by` char(36) not null,
|
||||
`stored_at` text,
|
||||
`upload_id` text,
|
||||
`declared_size` integer,
|
||||
`part_size` integer,
|
||||
`deleting_at` text
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `files_file` add constraint `files_file_org_id_workspace_id_project_id_storage_key_key` unique (`org_id`, `workspace_id`, `project_id`, `storage_key`);
|
||||
|
||||
create index `files_file_org_id_workspace_id_project_id_status_idx` on `files_file` (`org_id`, `workspace_id`, `project_id`, `status`(191));
|
||||
|
||||
create index `files_file_org_id_workspace_id_project_id_sha256_idx` on `files_file` (`org_id`, `workspace_id`, `project_id`, `sha256`(191));
|
||||
@@ -0,0 +1,28 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
create table `proposals` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`workspace_id` char(36) not null,
|
||||
`project_id` char(36) not null,
|
||||
`status` text not null,
|
||||
`target_key` text not null,
|
||||
`target_record_id` text,
|
||||
`written_record_id` text,
|
||||
`change` json not null,
|
||||
`evidence` json not null,
|
||||
`model` text not null,
|
||||
`prompt_version` text not null,
|
||||
`created_by` text not null,
|
||||
`edited_by` text,
|
||||
`edited_at` text,
|
||||
`decided_by` text,
|
||||
`decided_at` text,
|
||||
`reason` text
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
create index `proposals_org_id_workspace_id_project_id_status_idx` on `proposals` (`org_id`, `workspace_id`, `project_id`, `status`(191));
|
||||
|
||||
create index `proposals_org_id_workspace_id_project_id_target_key_tar_25412770` on `proposals` (`org_id`, `workspace_id`, `project_id`, `target_key`(191), `target_record_id`(191));
|
||||
@@ -0,0 +1,36 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
create table `app_user_identity` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`issuer` varchar(255) not null,
|
||||
`subject` varchar(255) not null,
|
||||
`user_id` char(36) not null,
|
||||
`migration_id` varchar(255)
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `app_user_identity` add constraint `app_user_identity_issuer_subject_key` unique (`issuer`, `subject`);
|
||||
|
||||
create index `app_user_identity_user_id_idx` on `app_user_identity` (`user_id`);
|
||||
|
||||
insert into `app_user_identity` (
|
||||
`id`,
|
||||
`version`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`issuer`,
|
||||
`subject`,
|
||||
`user_id`,
|
||||
`migration_id`
|
||||
)
|
||||
select
|
||||
`id`,
|
||||
1,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`issuer`,
|
||||
`subject`,
|
||||
`id`,
|
||||
'legacy-users-issuer-subject-v1'
|
||||
from `users`;
|
||||
@@ -0,0 +1,48 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
create table `tenancy_roles` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`key` text not null,
|
||||
`name` text not null,
|
||||
`level` text not null,
|
||||
`permissions` json not null,
|
||||
`known_permissions` json not null,
|
||||
`created_by` char(36),
|
||||
`revision` integer not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `tenancy_roles` add constraint `tenancy_roles_org_id_key_key` unique (`org_id`, `key`);
|
||||
|
||||
create table `project_memberships` (
|
||||
`id` char(36) primary key,
|
||||
`version` integer not null,
|
||||
`created_at` datetime(6) not null,
|
||||
`updated_at` datetime(6) not null,
|
||||
`org_id` char(36) not null,
|
||||
`project_id` char(36) not null,
|
||||
`user_id` char(36) not null,
|
||||
`role_key` text not null
|
||||
) engine=InnoDB default charset=utf8mb4;
|
||||
|
||||
alter table `project_memberships` add constraint `project_memberships_org_id_project_id_user_id_key` unique (`org_id`, `project_id`, `user_id`);
|
||||
|
||||
create index `project_memberships_org_id_user_id_idx` on `project_memberships` (`org_id`, `user_id`);
|
||||
|
||||
create index `project_memberships_org_id_role_key_idx` on `project_memberships` (`org_id`, `role_key`(191));
|
||||
|
||||
alter table `org_memberships` add column `role_key` text;
|
||||
|
||||
alter table `workspace_memberships` add column `role_key` text;
|
||||
|
||||
alter table `invitations` add column `role_key` text;
|
||||
|
||||
alter table `projects` add column `visibility` text;
|
||||
|
||||
create index `org_memberships_org_id_role_key_idx` on `org_memberships` (`org_id`, `role_key`(191));
|
||||
|
||||
create index `workspace_memberships_org_id_role_key_idx` on `workspace_memberships` (`org_id`, `role_key`(191));
|
||||
|
||||
create index `invitations_org_id_role_key_idx` on `invitations` (`org_id`, `role_key`(191));
|
||||
@@ -0,0 +1,2 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
alter table `projects` add column `description` text;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
alter table `invitations` add column `revoked_at` text;
|
||||
Reference in New Issue
Block a user