-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes the association between Category and Tag table
This commit includes following changes - Modifies category and tag table - Add Migration for tag table to drop category_id column and delete the category-tag constraints - Modifies category parsing logic Signed-off-by: Shiv Verma <[email protected]>
- Loading branch information
1 parent
29d53ef
commit df42890
Showing
7 changed files
with
52 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ type Data struct { | |
|
||
type Category struct { | ||
Name string | ||
Tags []string | ||
} | ||
|
||
type Catalog struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...tion/202105311800_remove_categoryid_column_and_category_tag_constraints_from_tag_table.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright © 2021 The Tekton Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package migration | ||
|
||
import ( | ||
"github.com/go-gormigrate/gormigrate/v2" | ||
"github.com/tektoncd/hub/api/gen/log" | ||
"github.com/tektoncd/hub/api/pkg/db/model" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func removeCatgoryIdColumnAndConstraintsFromTagtable(log *log.Logger) *gormigrate.Migration { | ||
|
||
return &gormigrate.Migration{ | ||
ID: "202105311800_remove_categoryid_column_and_category_tag_constraints_from_tag_table", | ||
Migrate: func(db *gorm.DB) error { | ||
|
||
if err := db.Migrator().DropConstraint(&model.Tag{}, "fk_categories_tags"); err != nil { | ||
log.Error(err) | ||
return err | ||
} | ||
|
||
if err := db.Migrator().DropConstraint(&model.Tag{}, "fk_tags_category"); err != nil { | ||
log.Error(err) | ||
return err | ||
} | ||
|
||
if err := db.Migrator().DropColumn(&model.Tag{}, "category_id"); err != nil { | ||
log.Error(err) | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters