mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 12:30:41 +01:00
fix(be): migrations for mysql and postgres
This commit is contained in:
parent
92895f9f3c
commit
cb5f27d9ed
@ -14,6 +14,8 @@ var (
|
||||
dateTimeTypeRE = regexp.MustCompile(`(?i)\bdatetime\b`)
|
||||
tinyintRE = regexp.MustCompile(`(?i)\btinyint\b`)
|
||||
longtextRE = regexp.MustCompile(`(?i)\blongtext\b`)
|
||||
ifExistsRE = regexp.MustCompile(`(?i)\bif exists\b`)
|
||||
dropForeignKey = regexp.MustCompile(`(?i)\bdrop foreign key\b`)
|
||||
)
|
||||
|
||||
// prepareMigration converts migration SQLite-query to current dialect.
|
||||
@ -22,12 +24,14 @@ func (d *SqlDb) prepareMigration(query string) string {
|
||||
switch d.sql.Dialect.(type) {
|
||||
case gorp.MySQLDialect:
|
||||
query = autoIncrementRE.ReplaceAllString(query, "auto_increment")
|
||||
query = ifExistsRE.ReplaceAllString(query, "")
|
||||
case gorp.PostgresDialect:
|
||||
query = serialRE.ReplaceAllString(query, "serial primary key")
|
||||
query = identifierQuoteRE.ReplaceAllString(query, "\"")
|
||||
query = dateTimeTypeRE.ReplaceAllString(query, "timestamp")
|
||||
query = tinyintRE.ReplaceAllString(query, "smallint")
|
||||
query = longtextRE.ReplaceAllString(query, "text")
|
||||
query = dropForeignKey.ReplaceAllString(query, "drop constraint")
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
ALTER TABLE project__inventory DROP FOREIGN KEY IF EXISTS project__inventory_ibfk_2;
|
||||
|
||||
alter table `project__inventory` drop column `key_id`;
|
||||
|
||||
ALTER TABLE project__template DROP FOREIGN KEY IF EXISTS project__template_ibfk_2;
|
||||
|
||||
alter table `project__template` drop column `ssh_key_id`;
|
@ -48,7 +48,7 @@ type ldapMappings struct {
|
||||
type ConfigType struct {
|
||||
MySQL DbConfig `json:"mysql"`
|
||||
BoltDb DbConfig `json:"bolt"`
|
||||
Postgres DbConfig `json:"pgsql"`
|
||||
Postgres DbConfig `json:"postgres"`
|
||||
|
||||
Dialect DbDriver `json:"dialect"`
|
||||
|
||||
@ -238,7 +238,7 @@ func (d *DbConfig) GetConnectionString(includeDbName bool) (connectionString str
|
||||
d.DbName)
|
||||
} else {
|
||||
connectionString = fmt.Sprintf(
|
||||
"postgres://%s:%s@%s/",
|
||||
"postgres://%s:%s@%s",
|
||||
d.Username,
|
||||
d.Password,
|
||||
d.Hostname)
|
||||
|
Loading…
Reference in New Issue
Block a user