-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e81d19a
commit 845db13
Showing
11 changed files
with
169 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package database | ||
|
||
import ( | ||
"database/sql" | ||
"log/slog" | ||
"runtime" | ||
) | ||
|
||
func DatabaseUpdate_update0016_update0017(db *sql.DB, getInfo bool) (string, string, string, error) { | ||
|
||
// WARNING!!! | ||
// Do not change the update if it has already been installed by other developers or in production. | ||
// To correct the database, create a new update and register it in the list of updates. | ||
|
||
fromUpdateId, toUpdateId := ParseNameFuncUpdate(runtime.Caller(0)) | ||
description := "Add role to profile and team history" | ||
if getInfo { | ||
return fromUpdateId, toUpdateId, description, nil | ||
} | ||
query := ` | ||
BEGIN; | ||
ALTER TABLE profiles ADD COLUMN role varchar(50) default 'player' NOT NULL; | ||
ALTER TABLE team_history ADD COLUMN role varchar(50) default 'player' NOT NULL; | ||
COMMIT; | ||
` | ||
_, err := db.Query(query) | ||
if err != nil { | ||
slog.Error("Problem with select, query: " + query + "\n error:" + err.Error()) | ||
return fromUpdateId, toUpdateId, description, err | ||
} | ||
return fromUpdateId, toUpdateId, description, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package database | ||
|
||
import ( | ||
"database/sql" | ||
"log/slog" | ||
"runtime" | ||
) | ||
|
||
func DatabaseUpdate_update0017_update0017testdata(db *sql.DB, getInfo bool) (string, string, string, error) { | ||
|
||
// WARNING!!! | ||
// Do not change the update if it has already been installed by other developers or in production. | ||
// To correct the database, create a new update and register it in the list of updates. | ||
|
||
fromUpdateId, toUpdateId := ParseNameFuncUpdate(runtime.Caller(0)) | ||
description := "Flush team_history table" | ||
if getInfo { | ||
return fromUpdateId, toUpdateId, description, nil | ||
} | ||
|
||
query := ` | ||
` | ||
_, err := db.Query(query) | ||
if err != nil { | ||
slog.Error("Problem with select, query: " + query + "\n error:" + err.Error()) | ||
return fromUpdateId, toUpdateId, description, err | ||
} | ||
return fromUpdateId, toUpdateId, description, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package database | ||
|
||
import ( | ||
"database/sql" | ||
"log/slog" | ||
"runtime" | ||
) | ||
|
||
func DatabaseUpdate_update0017_update0018(db *sql.DB, getInfo bool) (string, string, string, error) { | ||
|
||
// WARNING!!! | ||
// Do not change the update if it has already been installed by other developers or in production. | ||
// To correct the database, create a new update and register it in the list of updates. | ||
|
||
fromUpdateId, toUpdateId := ParseNameFuncUpdate(runtime.Caller(0)) | ||
description := "Add role to profile and team history" | ||
if getInfo { | ||
return fromUpdateId, toUpdateId, description, nil | ||
} | ||
query := ` | ||
BEGIN; | ||
ALTER TABLE profiles ADD COLUMN role varchar(50) default 'player' NOT NULL; | ||
ALTER TABLE team_history ADD COLUMN role varchar(50) default 'player' NOT NULL; | ||
COMMIT; | ||
` | ||
_, err := db.Query(query) | ||
if err != nil { | ||
slog.Error("Problem with select, query: " + query + "\n error:" + err.Error()) | ||
return fromUpdateId, toUpdateId, description, err | ||
} | ||
return fromUpdateId, toUpdateId, description, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters