mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 09:33:11 +00:00
d08f067e9c
A Bunch Tell is now Musing Studio.
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
/*
|
|
* Copyright © 2020-2021 Musing Studio LLC.
|
|
*
|
|
* This file is part of WriteFreely.
|
|
*
|
|
* WriteFreely is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License, included
|
|
* in the LICENSE file in this source code package.
|
|
*/
|
|
|
|
package migrations
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
wf_db "github.com/writefreely/writefreely/db"
|
|
)
|
|
|
|
func oauthAttach(db *datastore) error {
|
|
dialect := wf_db.DialectMySQL
|
|
if db.driverName == driverSQLite {
|
|
dialect = wf_db.DialectSQLite
|
|
}
|
|
return wf_db.RunTransactionWithOptions(context.Background(), db.DB, &sql.TxOptions{}, func(ctx context.Context, tx *sql.Tx) error {
|
|
builders := []wf_db.SQLBuilder{
|
|
dialect.
|
|
AlterTable("oauth_client_states").
|
|
AddColumn(dialect.
|
|
Column(
|
|
"attach_user_id",
|
|
wf_db.ColumnTypeInteger,
|
|
wf_db.OptionalInt{Set: true, Value: 24}).SetNullable(true)),
|
|
}
|
|
for _, builder := range builders {
|
|
query, err := builder.ToSQL()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if _, err := tx.ExecContext(ctx, query); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
}
|