setuptask.go ×11
Frontier kind: Code frontier
unlabeled · c_5b1f29d3f00a
19 tests · 2297 LOC · 109 files · introduces 0 tests · 50 LOC · 2 files
Introduces — evidence that enters the hierarchy at this concept
Code
15 ranges 50 lines · 2 files
Tests
0 tests
Contains — complete concept membership
Neighbourhood graph
The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.
Focus concept
Ancestors (broader)
Descendants (narrower)
Introduced files
Introduced tests
Introduced files, introduced tests, and structurally relevant concept specialization
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.
JavaScript is disabled; use the native relationship evidence on this page to explore the same evidence.
Native relationship evidence
Every exact file and test below is linked only from the concept that introduces it.
Introduced tests
Every collected test enters the hierarchy at exactly one concept.
No tests are introduced at this concept. Its intent tests are introduced by other concepts.
Introduced code
Every collected source range enters the hierarchy at exactly one concept.
2 files ranked by introduced lines: 50 introduced LOC across 15 ranges.
Expand a file to inspect source; the > gutter marks introduced lines.
go.temporal.io/server/tools/common/schema/setuptask.go 36 introduced LOC · 11 ranges
Open complete file
27
28
// NewSetupSchemaTask returns a new instance of SetupTask
29
>
func NewSetupSchemaTask ( db DB , config * SetupConfig , logger log . Logger ) * SetupTask {
setuptask.go
30
>
return & SetupTask {
31
>
db : db ,
32
>
config : config ,
33
>
logger : logger ,
34
>
}
35
>
}
36
37
// Run executes the task
39
>
config := task . config
40
>
task . logger . Info ( "Starting schema setup" , tag . Any ( "config" , config ))
41
>
42
>
if config . Overwrite {
43
err := task . db . DropAllTables ()
44
if err != nil {
47
}
48
50
>
task . logger . Debug ( "Setting up version tables" )
51
>
if err := task . db . CreateSchemaVersionTables (); err != nil {
52
return err
53
}
54
}
55
56
>
if len ( config . SchemaFilePath ) > 0 || len ( config . SchemaName ) > 0 {
setuptask.go
57
var schemaBuf [] byte
58
var err error
86
}
87
89
>
currVer , err := task . db . ReadSchemaVersion ()
90
>
if err != nil {
91
>
currVer = "0.0"
92
>
}
93
94
>
currVerParsed , err := semver . ParseTolerant ( currVer )
setuptask.go
95
>
if err != nil {
96
task . logger . Fatal ( "Unable to parse current version" ,
97
tag . String ( "current version" , currVer ),
100
}
101
102
>
initialVersionParsed , err := semver . ParseTolerant ( config . InitialVersion )
setuptask.go
103
>
if err != nil {
104
task . logger . Fatal ( "Unable to parse initial version" ,
105
tag . String ( "initial version" , config . InitialVersion ),
108
}
109
110
>
if currVerParsed . GT ( initialVersionParsed ) {
setuptask.go
111
task . logger . Debug ( fmt . Sprintf ( "Current database schema version %v is greater than initial schema version %v. Skip version upgrade" , currVer , config . InitialVersion ))
113
>
task . logger . Debug ( fmt . Sprintf ( "Setting initial schema version to %v" , config . InitialVersion ))
114
>
err := task . db . UpdateSchemaVersion ( config . InitialVersion , config . InitialVersion )
115
>
if err != nil {
116
return err
117
}
118
>
task . logger . Debug ( "Updating schema update log" )
setuptask.go
119
>
err = task . db . WriteSchemaUpdateLog ( "0" , config . InitialVersion , "" , "initial version" )
120
>
if err != nil {
121
return err
122
}
124
}
125
126
>
task . logger . Info ( "Schema setup complete" )
setuptask.go
127
>
128
>
return nil
129
}
go.temporal.io/server/tools/common/schema/handler.go 14 introduced LOC · 4 ranges
Open complete file
12
13
// Setup sets up schema tables
14
>
func Setup ( cli * cli . Context , db DB , logger log . Logger ) error {
handler.go
15
>
cfg , err := newSetupConfig ( cli , db )
16
>
if err != nil {
17
return err
18
}
19
>
return NewSetupSchemaTask ( db , cfg , logger ). Run ()
handler.go
20
}
21
41
}
42
43
>
func newSetupConfig ( cli * cli . Context , db DB ) ( * SetupConfig , error ) {
handler.go
44
>
config := new ( SetupConfig )
45
>
config . SchemaFilePath = cli . String ( CLIOptSchemaFile )
46
>
config . SchemaName = cli . String ( CLIOptSchemaName )
47
>
config . InitialVersion = cli . String ( CLIOptVersion )
48
>
config . DisableVersioning = cli . Bool ( CLIOptDisableVersioning )
49
>
config . Overwrite = cli . Bool ( CLIOptOverwrite )
50
>
51
>
if err := validateSetupConfig ( config , db ); err != nil {
52
return nil , err
53
}
55
}
56