A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

46 linhas
1.1 KiB

  1. /*
  2. * Copyright © 2020-2021 Musing Studio LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package migrations
  11. import (
  12. "context"
  13. "database/sql"
  14. wf_db "github.com/writefreely/writefreely/db"
  15. )
  16. func oauthInvites(db *datastore) error {
  17. dialect := wf_db.DialectMySQL
  18. if db.driverName == driverSQLite {
  19. dialect = wf_db.DialectSQLite
  20. }
  21. return wf_db.RunTransactionWithOptions(context.Background(), db.DB, &sql.TxOptions{}, func(ctx context.Context, tx *sql.Tx) error {
  22. builders := []wf_db.SQLBuilder{
  23. dialect.
  24. AlterTable("oauth_client_states").
  25. AddColumn(dialect.Column("invite_code", wf_db.ColumnTypeChar, wf_db.OptionalInt{
  26. Set: true,
  27. Value: 6,
  28. }).SetNullable(true)),
  29. }
  30. for _, builder := range builders {
  31. query, err := builder.ToSQL()
  32. if err != nil {
  33. return err
  34. }
  35. if _, err := tx.ExecContext(ctx, query); err != nil {
  36. return err
  37. }
  38. }
  39. return nil
  40. })
  41. }