diff --git a/migration/migration_blackbox_test.go b/migration/migration_blackbox_test.go index a9eba61..63ff4f3 100644 --- a/migration/migration_blackbox_test.go +++ b/migration/migration_blackbox_test.go @@ -162,4 +162,26 @@ func testMigration004AddCapacityExhaustedToCluster(t *testing.T) { require.NoError(t, err) assert.True(t, dialect.HasColumn("cluster", "capacity_exhausted")) + + _, err = sqlDB.Exec(`INSERT INTO cluster (cluster_id, created_at, updated_at, name, url, console_url, + metrics_url, logging_url, app_dns, sa_token, sa_username, token_provider_id, + auth_client_id, auth_client_secret, auth_default_scope, type) + VALUES ('1b3d3751-69a7-4981-bf6f-63cd08b723af', now(), now(), 'exhausted', 'https://exhausted.api.cluster.com', 'https://console.cluster.com', + 'https://metrics.cluster.com', 'https://login.cluster.com', 'https://app.cluster.com', 'sometoken', 'dssas-sre', 'pr-id', + 'client-id', 'cleint-scr', 'somescope', 'OSD')`) + require.NoError(t, err) + + // check if ALL the existing rows & new rows have the default value + rows, err := sqlDB.Query("SELECT capacity_exhausted FROM cluster") + fmt.Println(rows.Columns()) + if err != nil { + t.Fatal(err) + } + defer rows.Close() + for rows.Next() { + var capacity_exhausted bool + err = rows.Scan(&capacity_exhausted) + require.NoError(t, err) + assert.False(t, capacity_exhausted) + } } diff --git a/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql b/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql index 1bc12d7..69f489f 100644 --- a/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql +++ b/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql @@ -1,2 +1,2 @@ -- Store capacity_exhausted for cluster -ALTER TABLE cluster ADD COLUMN capacity_exhausted boolean; +ALTER TABLE cluster ADD COLUMN capacity_exhausted boolean NOT NULL DEFAULT FALSE; \ No newline at end of file