Skip to content

Commit

Permalink
Serialize/deserialize drop multicolumn constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Nov 26, 2024
1 parent 63a0c40 commit a3e0b28
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions pkg/migrations/op_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ import (
type OpName string

const (
OpNameCreateTable OpName = "create_table"
OpNameRenameTable OpName = "rename_table"
OpNameDropTable OpName = "drop_table"
OpNameAddColumn OpName = "add_column"
OpNameDropColumn OpName = "drop_column"
OpNameAlterColumn OpName = "alter_column"
OpNameCreateIndex OpName = "create_index"
OpNameDropIndex OpName = "drop_index"
OpNameRenameConstraint OpName = "rename_constraint"
OpNameDropConstraint OpName = "drop_constraint"
OpNameSetReplicaIdentity OpName = "set_replica_identity"
OpRawSQLName OpName = "sql"
OpCreateConstraintName OpName = "create_constraint"
OpNameCreateTable OpName = "create_table"
OpNameRenameTable OpName = "rename_table"
OpNameDropTable OpName = "drop_table"
OpNameAddColumn OpName = "add_column"
OpNameDropColumn OpName = "drop_column"
OpNameAlterColumn OpName = "alter_column"
OpNameCreateIndex OpName = "create_index"
OpNameDropIndex OpName = "drop_index"
OpNameRenameConstraint OpName = "rename_constraint"
OpNameDropConstraint OpName = "drop_constraint"
OpNameSetReplicaIdentity OpName = "set_replica_identity"
OpNameDropMultiColumnConstraint OpName = "drop_multicolumn_constraint"
OpRawSQLName OpName = "sql"
OpCreateConstraintName OpName = "create_constraint"

// Internal operation types used by `alter_column`

Expand Down Expand Up @@ -129,6 +130,9 @@ func (v *Operations) UnmarshalJSON(data []byte) error {
case OpCreateConstraintName:
item = &OpCreateConstraint{}

case OpNameDropMultiColumnConstraint:
item = &OpDropMultiColumnConstraint{}

default:
return fmt.Errorf("unknown migration type: %v", opName)
}
Expand Down Expand Up @@ -218,6 +222,9 @@ func OperationName(op Operation) OpName {
case *OpCreateConstraint:
return OpCreateConstraintName

case *OpDropMultiColumnConstraint:
return OpNameDropMultiColumnConstraint

}

panic(fmt.Errorf("unknown operation for %T", op))
Expand Down

0 comments on commit a3e0b28

Please sign in to comment.