From 79972d3fb38b0e0ed83a365c378f212b92adc602 Mon Sep 17 00:00:00 2001 From: Wilian Gabriel <63816070+wiliansilvazup@users.noreply.github.com> Date: Thu, 17 Jun 2021 08:14:42 -0300 Subject: [PATCH] main (#48) * Horusec-Swift (#44) * Adding update analysis queue and exchange (#41) * Adding update analysis queue and exchange * Removing unnecessary typing form exchanges * Removing update exchange and queues * add language Swift (#43) Co-authored-by: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com> Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com> * Develop (#47) * Adding update analysis queue and exchange (#41) * Adding update analysis queue and exchange * Removing unnecessary typing form exchanges * Removing update exchange and queues * add language Swift (#43) * Adding owasp dependency check tool (#46) Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com> Co-authored-by: wilian * Remove migrations folder (#45) Co-authored-by: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com> Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com> --- .../20210419185606_initial_migration.down.sql | 8 - .../20210419185606_initial_migration.up.sql | 142 ------------------ ...100413_create_table_if_not_exists.down.sql | 13 -- ...08100413_create_table_if_not_exists.up.sql | 83 ---------- ...20200818092502_create_table_cache.down.sql | 5 - .../20200818092502_create_table_cache.up.sql | 12 -- ...00820125410_create_table_analysis.down.sql | 9 -- ...0200820125410_create_table_analysis.up.sql | 59 -------- .../20200925114542_vuln_hash.down.sql | 6 - .../platform/20200925114542_vuln_hash.up.sql | 7 - ...929095207_token_repositoryid_null.down.sql | 1 - ...00929095207_token_repositoryid_null.up.sql | 1 - ...25_remove-type-vulnerable-version.down.sql | 3 - ...4025_remove-type-vulnerable-version.up.sql | 3 - .../20201001094426_unique_names.down.sql | 5 - .../20201001094426_unique_names.up.sql | 5 - ..._create-nn-analysis-vulnerability.down.sql | 13 -- ...20_create-nn-analysis-vulnerability.up.sql | 16 -- ...01021174800_ldap_permission_group.down.sql | 14 -- ...0201021174800_ldap_permission_group.up.sql | 14 -- ...23190326_create-super-admin-field.down.sql | 5 - ...1023190326_create-super-admin-field.up.sql | 5 - .../platform/20201111195526_webhook.down.sql | 5 - .../platform/20201111195526_webhook.up.sql | 20 --- ...0129093830_ldap-groups-array-type.down.sql | 12 -- ...210129093830_ldap-groups-array-type.up.sql | 28 ---- ...301125133_update-token-no-expires.down.sql | 5 - ...10301125133_update-token-no-expires.up.sql | 5 - .../20210406121213_workspace_rename.down.sql | 33 ---- .../20210406121213_workspace_rename.up.sql | 33 ---- 30 files changed, 570 deletions(-) delete mode 100644 pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql delete mode 100644 pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201111195526_webhook.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201111195526_webhook.up.sql delete mode 100644 pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql delete mode 100644 pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql delete mode 100644 pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql delete mode 100644 pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql delete mode 100644 pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql delete mode 100644 pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql diff --git a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql b/pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql deleted file mode 100644 index 5cc04d2..0000000 --- a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql +++ /dev/null @@ -1,8 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS vulnerabilities_by_author CASCADE; -DROP TABLE IF EXISTS vulnerabilities_by_language CASCADE; -DROP TABLE IF EXISTS vulnerabilities_by_repository CASCADE; -DROP TABLE IF EXISTS vulnerabilities_by_time CASCADE; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql b/pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql deleted file mode 100644 index 8742cb0..0000000 --- a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql +++ /dev/null @@ -1,142 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_author" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "author" VARCHAR(500) NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_language" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "language" VARCHAR(255) NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_repository" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "repository_name" VARCHAR(255) NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_time" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql b/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql deleted file mode 100644 index b6f3cd1..0000000 --- a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS accounts CASCADE; - -DROP TABLE IF EXISTS companies CASCADE; - -DROP TABLE IF EXISTS account_company CASCADE; - -DROP TABLE IF EXISTS repositories CASCADE; - -DROP TABLE IF EXISTS account_repository CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql b/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql deleted file mode 100644 index f20fcc0..0000000 --- a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql +++ /dev/null @@ -1,83 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "accounts" -( - "account_id" UUID NOT NULL, - "password" VARCHAR(255) NOT NULL, - "email" VARCHAR(255) UNIQUE NOT NULL, - "username" VARCHAR(255) NOT NULL, - "is_confirmed" BOOLEAN NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (account_id) -); - -CREATE TABLE IF NOT EXISTS "companies" -( - "company_id" UUID NOT NULL, - "name" VARCHAR(255) NOT NULL, - "description" VARCHAR(255), - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (company_id) -); - -CREATE TABLE IF NOT EXISTS "account_company" -( - "company_id" UUID NOT NULL, - "account_id" UUID NOT NULL, - "role" VARCHAR(255) NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - FOREIGN KEY (company_id) REFERENCES companies (company_id) ON DELETE CASCADE, - FOREIGN KEY (account_id) REFERENCES accounts (account_id) ON DELETE CASCADE, - UNIQUE (company_id, account_id) - -); - -CREATE TABLE IF NOT EXISTS "repositories" -( - "repository_id" UUID NOT NULL, - "company_id" UUID NOT NULL, - "description" VARCHAR(255), - "name" VARCHAR(255) NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (repository_id), - FOREIGN KEY (company_id) REFERENCES companies (company_id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS "account_repository" -( - "repository_id" UUID NOT NULL, - "account_id" UUID NOT NULL, - "company_id" UUID NOT NULL, - "role" VARCHAR(255) NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - FOREIGN KEY (repository_id) REFERENCES repositories (repository_id) ON DELETE CASCADE, - FOREIGN KEY (account_id) REFERENCES accounts (account_id) ON DELETE CASCADE, - UNIQUE (repository_id, account_id) -); - -INSERT INTO accounts( - account_id, - password, - email, - username, - is_confirmed, - created_at, - updated_at) -VALUES ( - '4e0bfe1b-043d-4922-8198-07d84ab49bd0', - '$2a$10$hWoL3d6iUUl3wFBXouGDB.p/uE/K3t1k5vVFdN981IpoZJY8wftPm', /* Devpass0* */ - 'dev@example.com', - 'dev', - true, - '2020-07-29', - '2020-07-29' -); - -COMMIT; - - diff --git a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql b/pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql deleted file mode 100644 index 08ae1ce..0000000 --- a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS cache CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql b/pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql deleted file mode 100644 index 53ed88c..0000000 --- a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "cache" -( - "key" TEXT NOT NULL, - "value" TEXT NOT NULL, - "expires_at" TIMESTAMP NOT NULL DEFAULT NOW(), - "created_at" TIMESTAMP NOT NULL DEFAULT NOW(), - PRIMARY KEY (key) -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql b/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql deleted file mode 100644 index 9ab19f8..0000000 --- a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS tokens CASCADE; - -DROP TABLE IF EXISTS vulnerabilities CASCADE; - -DROP TABLE IF EXISTS analysis CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql b/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql deleted file mode 100644 index a28c80f..0000000 --- a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql +++ /dev/null @@ -1,59 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "analysis" -( - analysis_id UUID NOT NULL, - repository_id UUID NOT NULL, - repository_name VARCHAR(255) NOT NULL, - company_id UUID NOT NULL, - company_name VARCHAR(255) NOT NULL, - status VARCHAR(255) NOT NULL, - errors TEXT NOT NULL, - created_at DATE NOT NULL, - finished_at DATE NOT NULL, - PRIMARY KEY (analysis_id), - FOREIGN KEY (repository_id) REFERENCES "repositories" (repository_id) ON DELETE CASCADE, - FOREIGN KEY (company_id) REFERENCES "companies" (company_id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities" -( - vulnerability_id UUID NOT NULL, - analysis_id UUID NOT NULL, - line VARCHAR(255), - "column" VARCHAR(255), - confidence VARCHAR(255), - file VARCHAR, - code VARCHAR, - details VARCHAR, - type VARCHAR(255), - vulnerable_below VARCHAR(255), - version VARCHAR(255), - security_tool VARCHAR(255) NOT NULL, - language VARCHAR(255) NOT NULL, - severity VARCHAR(255), - commit_author VARCHAR(255), - commit_email VARCHAR(255), - commit_hash VARCHAR(255), - commit_message VARCHAR, - commit_date VARCHAR(255), - PRIMARY KEY (vulnerability_id), - FOREIGN KEY (analysis_id) REFERENCES "analysis" (analysis_id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS "tokens" -( - token_id UUID NOT NULL, - description VARCHAR(255) NOT NULL, - repository_id UUID NOT NULL, - company_id UUID NOT NULL, - suffix_value VARCHAR(255) NOT NULL, - value VARCHAR(255) NOT NULL, - created_at DATE NOT NULL, - expires_at DATE NOT NULL, - PRIMARY KEY (token_id), - FOREIGN KEY (repository_id) REFERENCES "repositories" (repository_id) ON DELETE CASCADE, - FOREIGN KEY (company_id) REFERENCES "companies" (company_id) ON DELETE CASCADE -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql b/pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql deleted file mode 100644 index 64657bd..0000000 --- a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE "vulnerabilities" -DROP COLUMN "vuln_hash"; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql b/pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql deleted file mode 100644 index a59f9c9..0000000 --- a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE "vulnerabilities" -ADD - "vuln_hash" VARCHAR(40); - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql b/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql deleted file mode 100644 index 4e890d5..0000000 --- a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE tokens ALTER COLUMN repository_id SET NOT NULL; diff --git a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql b/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql deleted file mode 100644 index dadccf4..0000000 --- a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE tokens ALTER COLUMN repository_id DROP NOT NULL; diff --git a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql b/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql deleted file mode 100644 index bbc9da5..0000000 --- a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE vulnerabilities ADD type VARCHAR(255); -ALTER TABLE vulnerabilities ADD vulnerable_below VARCHAR(255); -ALTER TABLE vulnerabilities ADD version VARCHAR(255); diff --git a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql b/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql deleted file mode 100644 index 59b8dbb..0000000 --- a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE vulnerabilities DROP COLUMN "type"; -ALTER TABLE vulnerabilities DROP COLUMN vulnerable_below; -ALTER TABLE vulnerabilities DROP COLUMN "version"; diff --git a/pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql b/pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql deleted file mode 100644 index 28d4ef4..0000000 --- a/pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts DROP CONSTRAINT uk_accounts_username; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql b/pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql deleted file mode 100644 index dbcb20e..0000000 --- a/pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts ADD CONSTRAINT uk_accounts_username UNIQUE (username); - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql b/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql deleted file mode 100644 index bb0b3f4..0000000 --- a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS analysis_vulnerabilities CASCADE; - -ALTER TABLE vulnerabilities DROP COLUMN "type"; - -ALTER TABLE vulnerabilities ADD analysis_id UUID NOT NULL; - -ALTER TABLE vulnerabilities ADD FOREIGN KEY (analysis_id) REFERENCES analysis (analysis_id) ON DELETE CASCADE; - -ALTER TABLE vulnerabilities ALTER COLUMN vuln_hash TYPE varchar(40) USING vuln_hash::varchar; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql b/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql deleted file mode 100644 index d51eca0..0000000 --- a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql +++ /dev/null @@ -1,16 +0,0 @@ -ALTER TABLE vulnerabilities DROP CONSTRAINT vulnerabilities_analysis_id_fkey; - -ALTER TABLE vulnerabilities DROP COLUMN analysis_id; - -ALTER TABLE vulnerabilities ADD COLUMN "type" varchar(255) NOT NULL; - -ALTER TABLE vulnerabilities ALTER COLUMN vuln_hash TYPE varchar(255) USING vuln_hash::varchar; - -CREATE TABLE analysis_vulnerabilities ( - vulnerability_id uuid NOT NULL, - analysis_id uuid NOT NULL, - created_at DATE NOT NULL, - FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities (vulnerability_id) ON DELETE CASCADE, - FOREIGN KEY (analysis_id) REFERENCES analysis (analysis_id) ON DELETE CASCADE, - PRIMARY KEY (analysis_id, vulnerability_id) -); diff --git a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql b/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql deleted file mode 100644 index 2274eaa..0000000 --- a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN; - -ALTER TABLE companies - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin; - -ALTER TABLE repositories - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin, - DROP COLUMN IF EXISTS authz_supervisor; - -ALTER TABLE "accounts" ALTER COLUMN "password" SET NOT NULL; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql b/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql deleted file mode 100644 index 66b2d2b..0000000 --- a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN; - -ALTER TABLE "companies" - ADD COLUMN "authz_member" VARCHAR(255), - ADD COLUMN "authz_admin" VARCHAR(255); - -ALTER TABLE "repositories" - ADD COLUMN "authz_member" VARCHAR(255), - ADD COLUMN "authz_admin" VARCHAR(255), - ADD COLUMN "authz_supervisor" VARCHAR(255); - -ALTER TABLE "accounts" ALTER COLUMN "password" DROP NOT NULL; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql b/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql deleted file mode 100644 index e70296b..0000000 --- a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts DROP COLUMN "is_application_admin"; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql b/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql deleted file mode 100644 index af96b64..0000000 --- a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts ADD COLUMN "is_application_admin" boolean NOT NULL DEFAULT false; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201111195526_webhook.down.sql b/pkg/services/database/migrations/platform/20201111195526_webhook.down.sql deleted file mode 100644 index d3041f9..0000000 --- a/pkg/services/database/migrations/platform/20201111195526_webhook.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS webhooks CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20201111195526_webhook.up.sql b/pkg/services/database/migrations/platform/20201111195526_webhook.up.sql deleted file mode 100644 index b31ea46..0000000 --- a/pkg/services/database/migrations/platform/20201111195526_webhook.up.sql +++ /dev/null @@ -1,20 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "webhooks" -( - "webhook_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "company_id" UUID NOT NULL, - "description" VARCHAR(255), - "method" VARCHAR(255) NOT NULL, - "url" VARCHAR(500) NOT NULL, - "headers" JSONB, - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (webhook_id), - FOREIGN KEY (repository_id) REFERENCES repositories (repository_id) ON DELETE CASCADE, - FOREIGN KEY (company_id) REFERENCES companies (company_id) ON DELETE CASCADE, - UNIQUE (repository_id) -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql b/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql deleted file mode 100644 index 23aa1b6..0000000 --- a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN; - -ALTER TABLE IF EXISTS workspaces - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin; - -ALTER TABLE IF EXISTS repositories - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin, - DROP COLUMN IF EXISTS authz_supervisor; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql b/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql deleted file mode 100644 index c44b622..0000000 --- a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql +++ /dev/null @@ -1,28 +0,0 @@ -BEGIN; - -alter table companies - alter authz_member drop default, - alter authz_member type text[] using array[authz_member], - alter authz_member set default '{}'; - -alter table companies - alter authz_admin drop default, - alter authz_admin type text[] using array[authz_admin], - alter authz_admin set default '{}'; - -alter table repositories - alter authz_member drop default, - alter authz_member type text[] using array[authz_member], - alter authz_member set default '{}'; - -alter table repositories - alter authz_supervisor drop default, - alter authz_supervisor type text[] using array[authz_supervisor], - alter authz_supervisor set default '{}'; - -alter table repositories - alter authz_admin drop default, - alter authz_admin type text[] using array[authz_admin], - alter authz_admin set default '{}'; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql b/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql deleted file mode 100644 index cb82b9b..0000000 --- a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE "tokens" DROP COLUMN "is_expirable"; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql b/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql deleted file mode 100644 index 15023e5..0000000 --- a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE "tokens" ADD "is_expirable" BOOLEAN default true; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql b/pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql deleted file mode 100644 index 76640cf..0000000 --- a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql +++ /dev/null @@ -1,33 +0,0 @@ -BEGIN; - -ALTER TABLE workspaces - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE workspaces - RENAME TO companies; - -ALTER TABLE account_workspace - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE account_workspace - RENAME TO account_company; - -ALTER TABLE analysis - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE analysis - RENAME COLUMN workspace_name TO company_name; - -ALTER TABLE webhooks - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE tokens - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE repositories - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE account_repository - RENAME COLUMN workspace_id TO company_id; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql b/pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql deleted file mode 100644 index a886a36..0000000 --- a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql +++ /dev/null @@ -1,33 +0,0 @@ -BEGIN; - -ALTER TABLE companies - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE companies - RENAME TO workspaces; - -ALTER TABLE account_company - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE account_company - RENAME TO account_workspace; - -ALTER TABLE analysis - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE analysis - RENAME COLUMN company_name TO workspace_name; - -ALTER TABLE webhooks - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE tokens - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE repositories - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE account_repository - RENAME COLUMN company_id TO workspace_id; - -COMMIT;