A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.1 KiB

  1. /*
  2. * Copyright © 2019 A Bunch Tell 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. func supportUserInvites(db *datastore) error {
  12. t, err := db.Begin()
  13. if err != nil {
  14. return err
  15. }
  16. _, err = t.Exec(`CREATE TABLE userinvites (
  17. id ` + db.typeChar(6) + ` NOT NULL ,
  18. owner_id ` + db.typeInt() + ` NOT NULL ,
  19. max_uses ` + db.typeSmallInt() + ` NULL ,
  20. created ` + db.typeDateTime() + ` NOT NULL ,
  21. expires ` + db.typeDateTime() + ` NULL ,
  22. inactive ` + db.typeBool() + ` NOT NULL ,
  23. PRIMARY KEY (id)
  24. ) ` + db.engine() + `;`)
  25. if err != nil {
  26. t.Rollback()
  27. return err
  28. }
  29. _, err = t.Exec(`CREATE TABLE usersinvited (
  30. invite_id ` + db.typeChar(6) + ` NOT NULL ,
  31. user_id ` + db.typeInt() + ` NOT NULL ,
  32. PRIMARY KEY (invite_id, user_id)
  33. ) ` + db.engine() + `;`)
  34. if err != nil {
  35. t.Rollback()
  36. return err
  37. }
  38. err = t.Commit()
  39. if err != nil {
  40. t.Rollback()
  41. return err
  42. }
  43. return nil
  44. }