From a52579cde5a857c5b130e21c60c0bc655ac978c9 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Wed, 3 Aug 2022 16:36:51 -0500 Subject: [PATCH] Add a table for controls This table adds a basic schema for controls, which will be referenced by results. Ideally, this control information will supplement information from other sources like OSCAL catalogs, which should be the preferred source of information, since it comes from the profile/standard authors. This schema is being discussed in issue #84. --- migrations/000008_create_controls_table.down.sql | 1 + migrations/000008_create_controls_table.up.sql | 9 +++++++++ tests/integration_test.go | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 migrations/000008_create_controls_table.down.sql create mode 100644 migrations/000008_create_controls_table.up.sql diff --git a/migrations/000008_create_controls_table.down.sql b/migrations/000008_create_controls_table.down.sql new file mode 100644 index 00000000..57e0dc9b --- /dev/null +++ b/migrations/000008_create_controls_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS controls; diff --git a/migrations/000008_create_controls_table.up.sql b/migrations/000008_create_controls_table.up.sql new file mode 100644 index 00000000..5d7f0bc6 --- /dev/null +++ b/migrations/000008_create_controls_table.up.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS controls ( + id uuid PRIMARY KEY, + name VARCHAR(255), + severity VARCHAR(50), + profile_id UUID, + metadata_id UUID, + CONSTRAINT fk_controls_metadata_id FOREIGN KEY (metadata_id) REFERENCES metadata (id), + CONSTRAINT fk_controls_profile_id FOREIGN KEY (profile_id) REFERENCES profiles (id) +); diff --git a/tests/integration_test.go b/tests/integration_test.go index ee10d6f6..98d3f723 100644 --- a/tests/integration_test.go +++ b/tests/integration_test.go @@ -303,7 +303,7 @@ func TestMigration(t *testing.T) { // nolint:paralleltest // database tests shou // Upgrade the database and make sure all upgrades apply cleanly. err = m.Up() version, dirty, _ = m.Version() - expectedVersion = uint(7) + expectedVersion = uint(8) assert.Equal(t, expectedVersion, version, "Database version mismatch: want %d but got %d", expectedVersion, version) assert.Equal(t, false, dirty, "Database state mismatch: want %t but got %t", false, dirty) assert.Equal(t, err, nil, "Error upgrading the database: %s", err)