|
| 1 | +package migration |
| 2 | + |
| 3 | +import ( |
| 4 | + "database/sql" |
| 5 | + "github.com/pressly/goose" |
| 6 | + "path/filepath" |
| 7 | +) |
| 8 | + |
| 9 | +func initialize20210719190719() { |
| 10 | + if _, ok := initializedMigrations[20210719190719]; !ok { |
| 11 | + goose.AddMigration(Up20210719190719, Down20210719190719) |
| 12 | + initializedMigrations[20210719190719] = true |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +// Up20210719190719 updates the workspace templates to use new v1.0.0 of filesyncer |
| 17 | +func Up20210719190719(tx *sql.Tx) error { |
| 18 | + // This code is executed when the migration is applied. |
| 19 | + if err := updateWorkspaceTemplateManifest( |
| 20 | + filepath.Join("workspaces", "cvat", "20210719190719.yaml"), |
| 21 | + cvatTemplateName); err != nil { |
| 22 | + return err |
| 23 | + } |
| 24 | + |
| 25 | + if err := updateWorkspaceTemplateManifest( |
| 26 | + filepath.Join("workspaces", "jupyterlab", "20210719190719.yaml"), |
| 27 | + jupyterLabTemplateName); err != nil { |
| 28 | + return err |
| 29 | + } |
| 30 | + |
| 31 | + if err := updateWorkspaceTemplateManifest( |
| 32 | + filepath.Join("workspaces", "vnc", "20210719190719.yaml"), |
| 33 | + deepLearningDesktopTemplateName); err != nil { |
| 34 | + return err |
| 35 | + } |
| 36 | + |
| 37 | + return updateWorkspaceTemplateManifest( |
| 38 | + filepath.Join("workspaces", "vscode", "20210719190719.yaml"), |
| 39 | + vscodeWorkspaceTemplateName) |
| 40 | +} |
| 41 | + |
| 42 | +// Down20210719190719 rolls back the change to update filesyncer |
| 43 | +func Down20210719190719(tx *sql.Tx) error { |
| 44 | + // This code is executed when the migration is rolled back. |
| 45 | + if err := updateWorkspaceTemplateManifest( |
| 46 | + filepath.Join("workspaces", "cvat", "20210323175655.yaml"), |
| 47 | + cvatTemplateName); err != nil { |
| 48 | + return err |
| 49 | + } |
| 50 | + |
| 51 | + if err := updateWorkspaceTemplateManifest( |
| 52 | + filepath.Join("workspaces", "jupyterlab", "20210323175655.yaml"), |
| 53 | + jupyterLabTemplateName); err != nil { |
| 54 | + return err |
| 55 | + } |
| 56 | + |
| 57 | + if err := updateWorkspaceTemplateManifest( |
| 58 | + filepath.Join("workspaces", "vnc", "20210414165510.yaml"), |
| 59 | + deepLearningDesktopTemplateName); err != nil { |
| 60 | + return err |
| 61 | + } |
| 62 | + |
| 63 | + return updateWorkspaceTemplateManifest( |
| 64 | + filepath.Join("workspaces", "vscode", "20210323175655.yaml"), |
| 65 | + vscodeWorkspaceTemplateName) |
| 66 | +} |
0 commit comments