Skip to content

Commit

Permalink
fix(sql): w_node_context constraint (#5163)
Browse files Browse the repository at this point in the history
Signed-off-by: francois  samin <[email protected]>
  • Loading branch information
fsamin authored May 6, 2020
1 parent 5cc5308 commit b65c968
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
13 changes: 5 additions & 8 deletions engine/api/integration/dao_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ func TestCRUDModel(t *testing.T) {
ok, err := ModelExists(db, p.Name)
require.NoError(t, err)

if ok {
p, err := LoadModelByName(db, p.Name)
if !ok {
err = InsertModel(db, p)
require.NoError(t, err)
// Eventually we have to clean all project_integration linked
_, err = db.Exec("delete from project_integration where integration_model_id = $1", p.ID)
} else {
p1, err := LoadModelByName(db, p.Name)
require.NoError(t, err)
require.NoError(t, DeleteModel(db, p.ID))
p = &p1
}

err = InsertModel(db, p)
require.NoError(t, err)

model, err := LoadModelByNameWithClearPassword(db, p.Name)
require.NoError(t, err)

Expand Down
9 changes: 5 additions & 4 deletions engine/api/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package api

import (
"context"
"net/url"
"strings"
"testing"
"time"

"github.com/ovh/cds/engine/api/authentication"
"github.com/ovh/cds/engine/api/authentication/builtin"
"github.com/ovh/cds/engine/api/test/assets"
"github.com/ovh/cds/engine/api/workflow"
"github.com/ovh/cds/sdk"
"github.com/ovh/cds/sdk/cdsclient"
"github.com/stretchr/testify/require"
"net/url"
"strings"
"testing"
"time"
)

func Test_websocketWrongFilters(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions engine/sql/200_fix_w_node_context_constraint.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- +migrate Up

ALTER TABLE "w_node_context" DROP CONSTRAINT IF EXISTS "fk_w_node_context_integration";
SELECT create_foreign_key('FK_W_NODE_CONTEXT_INTEGRATION', 'w_node_context', 'project_integration', 'project_integration_id', 'id');

-- +migrate Down
SELECT 1;

0 comments on commit b65c968

Please sign in to comment.