Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-orusapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
go-orusapi
Commits
0ebc121e41ca
Commit
0ebc121e41ca
authored
4 years ago
by
Christophe de Vienne
Browse files
Options
Downloads
Patches
Plain Diff
move the migration source to the migration package so it is accessible to packages outside cmd
parent
2f75d76afdfa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#6299
passed
4 years ago
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
templates/server/cmdMigrate.gotmpl
+1
-12
1 addition, 12 deletions
templates/server/cmdMigrate.gotmpl
templates/server/cmdServe.gotmpl
+2
-2
2 additions, 2 deletions
templates/server/cmdServe.gotmpl
templates/server/migration.gotmpl
+16
-0
16 additions, 0 deletions
templates/server/migration.gotmpl
with
19 additions
and
14 deletions
templates/server/cmdMigrate.gotmpl
+
1
−
12
View file @
0ebc121e
...
...
@@ -10,17 +10,6 @@
"{{ joinFilePath .TargetImportPath "migration" }}"
)
func initMigrationSource() source.Driver {
s := bindata.Resource(migration.AssetNames(), migration.Asset)
source, err := bindata.WithInstance(s)
if err != nil {
panic(err)
}
return source
}
var migrationSource = initMigrationSource()
// NewMigrateCmd instanciates a MigrateCmd
func NewMigrateCmd(dbOptions *database.Options, loggingOptions *orusapi.LoggingOptions) *MigrateCmd {
return &MigrateCmd{
...
...
@@ -39,7 +28,7 @@
func (cmd *MigrateCmd) Execute([]string) error {
cmd.log.SetMinLoggingLevel(zerolog.InfoLevel)
log := cmd.log.Logger()
m, err := database.NewMigrate(cmd.db.DSN, migrationSource)
m, err := database.NewMigrate(cmd.db.DSN, migration
.
Source)
if err != nil {
return fmt.Errorf("failed to init migration engine: %s", err)
}
...
...
This diff is collapsed.
Click to expand it.
templates/server/cmdServe.gotmpl
+
2
−
2
View file @
0ebc121e
...
...
@@ -41,7 +41,7 @@
// Execute setup a server and runs it
func (cmd *ServeCmd) Execute([]string) error {
if cmd.AutoMigrate {
if err := database.AutoMigrate(DatabaseOptions.DSN, migrationSource, Logger); err != nil {
if err := database.AutoMigrate(DatabaseOptions.DSN, migration
.
Source, Logger); err != nil {
return err
}
} else {
...
...
@@ -45,7 +45,7 @@
return err
}
} else {
if err := database.IsUptodate(DatabaseOptions.DSN, migrationSource); err != nil {
if err := database.IsUptodate(DatabaseOptions.DSN, migration
.
Source); err != nil {
return err
}
}
...
...
This diff is collapsed.
Click to expand it.
templates/server/migration.gotmpl
+
16
−
0
View file @
0ebc121e
...
...
@@ -2,5 +2,10 @@
package migration
import (
"github.com/golang-migrate/migrate/v4/source"
bindata "github.com/golang-migrate/migrate/v4/source/go_bindata"
)
//go:generate go-bindata -pkg migration -prefix scripts scripts
//go:generate sed -i "1s;^;// Code generated by go-bindata. DO NOT EDIT.\\n\\n;" bindata.go
...
...
@@ -5,2 +10,13 @@
//go:generate go-bindata -pkg migration -prefix scripts scripts
//go:generate sed -i "1s;^;// Code generated by go-bindata. DO NOT EDIT.\\n\\n;" bindata.go
func initSource() source.Driver {
s := bindata.Resource(AssetNames(), Asset)
source, err := bindata.WithInstance(s)
if err != nil {
panic(err)
}
return source
}
var Source = initSource()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment