From 4b577210debcf6dd4027923c27c70afe4ea39360 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Wed, 3 Aug 2022 16:30:30 -0500 Subject: [PATCH] Add a table for profiles This commit adds a table for profiles so that we can reference controls, and results to a parent profile. This table is not designed, at least initially, to store more than just a profile name and some metadata. This area will be tricky to navigate moving forward since it would be idea to rely on OSCAL defintions for profiles, and use OSCAL profiles distributed by standards bodies, and not maintain them in a service. This approach is being discussed in issue #84. Fixes #32 --- migrations/000007_create_profiles_table.down.sql | 1 + migrations/000007_create_profiles_table.up.sql | 9 +++++++++ tests/integration_test.go | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 migrations/000007_create_profiles_table.down.sql create mode 100644 migrations/000007_create_profiles_table.up.sql diff --git a/migrations/000007_create_profiles_table.down.sql b/migrations/000007_create_profiles_table.down.sql new file mode 100644 index 00000000..dcbc3511 --- /dev/null +++ b/migrations/000007_create_profiles_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS profiles; diff --git a/migrations/000007_create_profiles_table.up.sql b/migrations/000007_create_profiles_table.up.sql new file mode 100644 index 00000000..c63de0fe --- /dev/null +++ b/migrations/000007_create_profiles_table.up.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS profiles ( + id uuid PRIMARY KEY, + name VARCHAR(255), + metadata_id UUID, + catalog_id UUID, + CONSTRAINT fk_profiles_metadata_id FOREIGN KEY (metadata_id) REFERENCES metadata(id) + CONSTRAINT fk_profiles_catalog_id FOREIGN KEY (catalog_id) REFERENCES catalog(id) +); + diff --git a/tests/integration_test.go b/tests/integration_test.go index 46a9f963..ee10d6f6 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(6) + expectedVersion = uint(7) 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)