mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-22 06:38:32 -04:00
[CHORE] Remove Microsoft SQL Server Support
- Per https://codeberg.org/forgejo/discussions/issues/122
This commit is contained in:
parent
af47c583b4
commit
2d9afd0c21
70 changed files with 70 additions and 789 deletions
|
@ -45,32 +45,6 @@ func IncreaseLanguageField(x *xorm.Engine) error {
|
|||
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat MODIFY COLUMN language %s", sqlType)); err != nil {
|
||||
return err
|
||||
}
|
||||
case setting.Database.Type.IsMSSQL():
|
||||
// Yet again MSSQL just has to be awkward.
|
||||
// Here we have to drop the constraints first and then rebuild them
|
||||
constraints := make([]string, 0)
|
||||
if err := sess.SQL(`SELECT i.name AS Name
|
||||
FROM sys.indexes i INNER JOIN sys.index_columns ic
|
||||
ON i.index_id = ic.index_id AND i.object_id = ic.object_id
|
||||
INNER JOIN sys.tables AS t
|
||||
ON t.object_id = i.object_id
|
||||
INNER JOIN sys.columns c
|
||||
ON t.object_id = c.object_id AND ic.column_id = c.column_id
|
||||
WHERE t.name = 'language_stat' AND c.name = 'language'`).Find(&constraints); err != nil {
|
||||
return fmt.Errorf("Find constraints: %w", err)
|
||||
}
|
||||
for _, constraint := range constraints {
|
||||
if _, err := sess.Exec(fmt.Sprintf("DROP INDEX [%s] ON `language_stat`", constraint)); err != nil {
|
||||
return fmt.Errorf("Drop table `language_stat` constraint `%s`: %w", constraint, err)
|
||||
}
|
||||
}
|
||||
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language %s", sqlType)); err != nil {
|
||||
return err
|
||||
}
|
||||
// Finally restore the constraint
|
||||
if err := sess.CreateUniques(new(LanguageStat)); err != nil {
|
||||
return err
|
||||
}
|
||||
case setting.Database.Type.IsPostgreSQL():
|
||||
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language TYPE %s", sqlType)); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue