MCPcopy Index your code
hub / github.com/coder/coder / UpWithFS

Function UpWithFS

coderd/database/migrations/migrate.go:121–149  ·  view source on GitHub ↗

UpWithFS runs SQL migrations in the given fs.

(db *sql.DB, migs fs.FS)

Source from the content-addressed store, hash-verified

119
120// UpWithFS runs SQL migrations in the given fs.
121func UpWithFS(db *sql.DB, migs fs.FS) (retErr error) {
122 _, m, err := setup(db, migs)
123 if err != nil {
124 return xerrors.Errorf("migrate setup: %w", err)
125 }
126 defer func() {
127 srcErr, dbErr := m.Close()
128 if retErr != nil {
129 return
130 }
131 if dbErr != nil {
132 retErr = dbErr
133 return
134 }
135 retErr = srcErr
136 }()
137
138 err = m.Up()
139 if err != nil {
140 if errors.Is(err, migrate.ErrNoChange) {
141 // It's OK if no changes happened!
142 return nil
143 }
144
145 return xerrors.Errorf("up: %w", err)
146 }
147
148 return nil
149}
150
151// Down runs all down SQL migrations.
152func Down(db *sql.DB) error {

Callers 2

mainFunction · 0.92
UpFunction · 0.85

Calls 5

setupFunction · 0.70
CloseMethod · 0.65
UpMethod · 0.65
ErrorfMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected