@@ -14,9 +14,9 @@ import (
14
14
"github.com/xataio/pgroll/pkg/schema"
15
15
)
16
16
17
- // Duplicator duplicates a column in a table, including all constraints and
17
+ // duplicator duplicates a column in a table, including all constraints and
18
18
// comments.
19
- type Duplicator struct {
19
+ type duplicator struct {
20
20
stmtBuilder * duplicatorStmtBuilder
21
21
conn db.DB
22
22
columns map [string ]* columnToDuplicate
@@ -42,7 +42,7 @@ const (
42
42
)
43
43
44
44
// NewColumnDuplicator creates a new Duplicator for a column.
45
- func NewColumnDuplicator (conn db.DB , table * schema.Table , columns ... * schema.Column ) * Duplicator {
45
+ func NewColumnDuplicator (conn db.DB , table * schema.Table , columns ... * schema.Column ) * duplicator {
46
46
cols := make (map [string ]* columnToDuplicate , len (columns ))
47
47
for _ , column := range columns {
48
48
cols [column .Name ] = & columnToDuplicate {
@@ -51,7 +51,7 @@ func NewColumnDuplicator(conn db.DB, table *schema.Table, columns ...*schema.Col
51
51
withType : column .Type ,
52
52
}
53
53
}
54
- return & Duplicator {
54
+ return & duplicator {
55
55
stmtBuilder : & duplicatorStmtBuilder {
56
56
table : table ,
57
57
},
@@ -62,32 +62,32 @@ func NewColumnDuplicator(conn db.DB, table *schema.Table, columns ...*schema.Col
62
62
}
63
63
64
64
// WithType sets the type of the new column.
65
- func (d * Duplicator ) WithType (columnName , t string ) * Duplicator {
65
+ func (d * duplicator ) WithType (columnName , t string ) * duplicator {
66
66
d .columns [columnName ].withType = t
67
67
return d
68
68
}
69
69
70
70
// WithoutConstraint excludes a constraint from being duplicated.
71
- func (d * Duplicator ) WithoutConstraint (c string ) * Duplicator {
71
+ func (d * duplicator ) WithoutConstraint (c string ) * duplicator {
72
72
d .withoutConstraint = append (d .withoutConstraint , c )
73
73
return d
74
74
}
75
75
76
76
// WithoutNotNull excludes the NOT NULL constraint from being duplicated.
77
- func (d * Duplicator ) WithoutNotNull (columnName string ) * Duplicator {
77
+ func (d * duplicator ) WithoutNotNull (columnName string ) * duplicator {
78
78
d .columns [columnName ].withoutNotNull = true
79
79
return d
80
80
}
81
81
82
82
// WithName sets the name of the new column.
83
- func (d * Duplicator ) WithName (columnName , asName string ) * Duplicator {
83
+ func (d * duplicator ) WithName (columnName , asName string ) * duplicator {
84
84
d .columns [columnName ].asName = asName
85
85
return d
86
86
}
87
87
88
88
// Duplicate duplicates a column in the table, including all constraints and
89
89
// comments.
90
- func (d * Duplicator ) Duplicate (ctx context.Context ) error {
90
+ func (d * duplicator ) Execute (ctx context.Context ) error {
91
91
colNames := make ([]string , 0 , len (d .columns ))
92
92
for name , c := range d .columns {
93
93
colNames = append (colNames , name )
0 commit comments