From 2115f31f6c2e98e9d7b3bacd23281fc47d484fac Mon Sep 17 00:00:00 2001 From: Chris Rodriguez Date: Mon, 18 Nov 2024 11:58:11 -0500 Subject: [PATCH] Clean slate for beta --- api/Services/migrations/0000.js | 21 ------------ api/Services/migrations/0001.js | 23 ------------- api/Services/migrations/0002.js | 27 ---------------- api/Services/migrations/0003.js | 19 ----------- api/Services/migrations/0004.js | 27 ---------------- api/Services/migrations/0005.js | 19 ----------- api/Services/migrations/0006.js | 19 ----------- .../migrations/sql/current/10-cpat-tables.sql | 32 +++++++++++++------ .../migrations/sql/current/20-cpat-static.sql | 3 +- 9 files changed, 24 insertions(+), 166 deletions(-) delete mode 100644 api/Services/migrations/0000.js delete mode 100644 api/Services/migrations/0001.js delete mode 100644 api/Services/migrations/0002.js delete mode 100644 api/Services/migrations/0003.js delete mode 100644 api/Services/migrations/0004.js delete mode 100644 api/Services/migrations/0005.js delete mode 100644 api/Services/migrations/0006.js diff --git a/api/Services/migrations/0000.js b/api/Services/migrations/0000.js deleted file mode 100644 index b1cf8f36..00000000 --- a/api/Services/migrations/0000.js +++ /dev/null @@ -1,21 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `ALTER TABLE user - ADD COLUMN phoneNumber VARCHAR(20) NOT NULL DEFAULT '' AFTER email; - ` -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} - diff --git a/api/Services/migrations/0001.js b/api/Services/migrations/0001.js deleted file mode 100644 index b257cb2a..00000000 --- a/api/Services/migrations/0001.js +++ /dev/null @@ -1,23 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `ALTER TABLE collection -ADD COLUMN systemType VARCHAR(100) NULL DEFAULT NULL AFTER description, -ADD COLUMN systemName VARCHAR(100) NULL DEFAULT NULL AFTER systemType, -ADD COLUMN ccsafa VARCHAR(100) NULL DEFAULT NULL AFTER systemName, -ADD COLUMN aaPackage VARCHAR(100) NULL DEFAULT NULL AFTER ccsafa;` -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} - diff --git a/api/Services/migrations/0002.js b/api/Services/migrations/0002.js deleted file mode 100644 index ce76d286..00000000 --- a/api/Services/migrations/0002.js +++ /dev/null @@ -1,27 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `ALTER TABLE user DROP COLUMN isAdmin`, - - `ALTER TABLE assignedteams MODIFY COLUMN assignedTeamName VARCHAR(100) NOT NULL`, - - `ALTER TABLE user MODIFY COLUMN email VARCHAR(100) NOT NULL DEFAULT 'None Provided'`, - - `ALTER TABLE user DROP INDEX idx_user_email`, - - `ALTER TABLE user DROP INDEX userEmail_UNIQUE` -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} - diff --git a/api/Services/migrations/0003.js b/api/Services/migrations/0003.js deleted file mode 100644 index 3030c9cc..00000000 --- a/api/Services/migrations/0003.js +++ /dev/null @@ -1,19 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `ALTER TABLE poam ADD COLUMN localImpact VARCHAR(15) NULL DEFAULT '' AFTER likelihood`, -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} - diff --git a/api/Services/migrations/0004.js b/api/Services/migrations/0004.js deleted file mode 100644 index 7ea5c5b1..00000000 --- a/api/Services/migrations/0004.js +++ /dev/null @@ -1,27 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `CREATE TABLE poamassociatedvulnerabilities ( - poamId INT NOT NULL, - associatedVulnerability VARCHAR(15) NOT NULL, - PRIMARY KEY (poamId, associatedVulnerability), - CONSTRAINT fk_poam_vulnerability - FOREIGN KEY (poamId) - REFERENCES poam(poamId) - ON DELETE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci` -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) - -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} \ No newline at end of file diff --git a/api/Services/migrations/0005.js b/api/Services/migrations/0005.js deleted file mode 100644 index 2fdd2ae5..00000000 --- a/api/Services/migrations/0005.js +++ /dev/null @@ -1,19 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `ALTER TABLE poam CHANGE COLUMN stigTitle vulnerabilityTitle VARCHAR(255) NULL DEFAULT NULL`, -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) - -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} \ No newline at end of file diff --git a/api/Services/migrations/0006.js b/api/Services/migrations/0006.js deleted file mode 100644 index aca4d3ca..00000000 --- a/api/Services/migrations/0006.js +++ /dev/null @@ -1,19 +0,0 @@ -const MigrationHandler = require('./lib/MigrationHandler') - -const upMigration = [ - `ALTER TABLE poam DROP COLUMN notes`, -] - -const downMigration = [ -] - -const migrationHandler = new MigrationHandler(upMigration, downMigration) - -module.exports = { - up: async (pool) => { - await migrationHandler.up(pool, __filename) - }, - down: async (pool) => { - await migrationHandler.down(pool, __filename) - } -} \ No newline at end of file diff --git a/api/Services/migrations/sql/current/10-cpat-tables.sql b/api/Services/migrations/sql/current/10-cpat-tables.sql index e1b7bb13..1f43d86d 100644 --- a/api/Services/migrations/sql/current/10-cpat-tables.sql +++ b/api/Services/migrations/sql/current/10-cpat-tables.sql @@ -77,7 +77,7 @@ CREATE TABLE `assetlabels` ( DROP TABLE IF EXISTS `assignedteams`; CREATE TABLE `assignedteams` ( `assignedTeamId` int NOT NULL AUTO_INCREMENT, - `assignedTeamName` varchar(50) NOT NULL, + `assignedTeamName` varchar(100) NOT NULL, PRIMARY KEY (`assignedTeamId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; @@ -90,6 +90,10 @@ CREATE TABLE `collection` ( `collectionId` int NOT NULL AUTO_INCREMENT, `collectionName` varchar(50) NOT NULL, `description` varchar(255) DEFAULT NULL, + `systemType` varchar(100) DEFAULT NULL, + `systemName` varchar(100) DEFAULT NULL, + `ccsafa` varchar(100) DEFAULT NULL, + `aaPackage` varchar(100) DEFAULT NULL, `created` datetime DEFAULT CURRENT_TIMESTAMP, `collectionOrigin` varchar(15) DEFAULT 'C-PAT', `originCollectionId` int DEFAULT NULL, @@ -225,7 +229,7 @@ CREATE TABLE `poam` ( `iavmNumber` varchar(25) DEFAULT '', `iavComplyByDate` date DEFAULT NULL, `taskOrderNumber` varchar(25) DEFAULT NULL, - `stigTitle` varchar(255) DEFAULT NULL, + `vulnerabilityTitle` varchar(255) DEFAULT NULL, `stigBenchmarkId` varchar(255) DEFAULT NULL, `stigCheckData` text, `tenablePluginData` text, @@ -238,13 +242,13 @@ CREATE TABLE `poam` ( `predisposingConditions` varchar(2000) DEFAULT '', `severity` varchar(25) DEFAULT '', `likelihood` varchar(15) DEFAULT '', + `localImpact` varchar(15) DEFAULT '', `impactDescription` varchar(2000) DEFAULT '', `extensionTimeAllowed` int DEFAULT '0', `extensionJustification` varchar(2000) DEFAULT '', `hqs` tinyint(1) NOT NULL DEFAULT '0', `created` date NOT NULL DEFAULT (curdate()), `lastUpdated` date DEFAULT NULL, - `notes` varchar(500) DEFAULT '', PRIMARY KEY (`poamId`), UNIQUE KEY `poamID_UNIQUE` (`poamId`), KEY `idx_poam_collectionId` (`collectionId`), @@ -460,6 +464,18 @@ DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `poamassociatedvulnerabilities` +-- + +DROP TABLE IF EXISTS `poamassociatedvulnerabilities`; +CREATE TABLE `poamassociatedvulnerabilities` ( + `poamId` int NOT NULL, + `associatedVulnerability` varchar(15) NOT NULL, + PRIMARY KEY (`poamId`,`associatedVulnerability`), + CONSTRAINT `fk_poam_vulnerability` FOREIGN KEY (`poamId`) REFERENCES `poam` (`poamId`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + -- -- Table structure for table `poamattachments` -- @@ -637,7 +653,8 @@ DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `userId` int NOT NULL AUTO_INCREMENT, `userName` varchar(20) NOT NULL, - `email` varchar(100) NOT NULL DEFAULT '', + `email` varchar(100) NOT NULL DEFAULT 'None Provided', + `phoneNumber` varchar(20) NOT NULL DEFAULT '', `firstName` varchar(50) NOT NULL DEFAULT '', `lastName` varchar(50) NOT NULL DEFAULT ' ', `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -647,14 +664,11 @@ CREATE TABLE `user` ( `fullName` varchar(100) DEFAULT NULL, `officeOrg` varchar(100) DEFAULT 'UNKNOWN', `defaultTheme` varchar(50) DEFAULT 'lara-dark-blue', - `isAdmin` int NOT NULL DEFAULT '0', `lastClaims` json DEFAULT (_utf8mb4'{}'), `points` int NOT NULL DEFAULT '0', PRIMARY KEY (`userId`), - UNIQUE KEY `userEmail_UNIQUE` (`email`) USING BTREE, UNIQUE KEY `userName_UNIQUE` (`userName`), - KEY `idx_user_userName` (`userName`), - KEY `idx_user_email` (`email`) + KEY `idx_user_userName` (`userName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -664,4 +678,4 @@ CREATE TABLE `user` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-09-25 17:28:18 +-- Dump completed on 2024-11-18 11:46:49 diff --git a/api/Services/migrations/sql/current/20-cpat-static.sql b/api/Services/migrations/sql/current/20-cpat-static.sql index 5be094f4..ee43c3cf 100644 --- a/api/Services/migrations/sql/current/20-cpat-static.sql +++ b/api/Services/migrations/sql/current/20-cpat-static.sql @@ -18,7 +18,6 @@ LOCK TABLES `_migrations` WRITE; /*!40000 ALTER TABLE `_migrations` DISABLE KEYS */; -INSERT INTO `_migrations` VALUES ('2024-09-24 11:51:19',NULL,'0000.js'),('2024-09-24 12:13:34',NULL,'0001.js'),('2024-09-25 15:05:38',NULL,'0002.js'); /*!40000 ALTER TABLE `_migrations` ENABLE KEYS */; UNLOCK TABLES; @@ -39,4 +38,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-09-25 17:28:18 +-- Dump completed on 2024-11-18 11:46:49