MCPcopy
hub / github.com/writefreely/writefreely / oauthAttach

Function oauthAttach

migrations/v7.go:20–46  ·  view source on GitHub ↗
(db *datastore)

Source from the content-addressed store, hash-verified

18)
19
20func oauthAttach(db *datastore) error {
21 dialect := wf_db.DialectMySQL
22 if db.driverName == driverSQLite {
23 dialect = wf_db.DialectSQLite
24 }
25 return wf_db.RunTransactionWithOptions(context.Background(), db.DB, &sql.TxOptions{}, func(ctx context.Context, tx *sql.Tx) error {
26 builders := []wf_db.SQLBuilder{
27 dialect.
28 AlterTable("oauth_client_states").
29 AddColumn(dialect.
30 Column(
31 "attach_user_id",
32 wf_db.ColumnTypeInteger,
33 wf_db.OptionalInt{Set: true, Value: 24}).SetNullable(true)),
34 }
35 for _, builder := range builders {
36 query, err := builder.ToSQL()
37 if err != nil {
38 return err
39 }
40 if _, err := tx.ExecContext(ctx, query); err != nil {
41 return err
42 }
43 }
44 return nil
45 })
46}

Callers

nothing calls this directly

Calls 5

AddColumnMethod · 0.80
AlterTableMethod · 0.80
SetNullableMethod · 0.80
ToSQLMethod · 0.65
ColumnMethod · 0.45

Tested by

no test coverage detected