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.
 
 
 
 
 

47 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. _, err = t.Exec(`CREATE TABLE userinvites (
  14. id ` + db.typeChar(6) + ` NOT NULL ,
  15. owner_id ` + db.typeInt() + ` NOT NULL ,
  16. max_uses ` + db.typeSmallInt() + ` NULL ,
  17. created ` + db.typeDateTime() + ` NOT NULL ,
  18. expires ` + db.typeDateTime() + ` NULL ,
  19. inactive ` + db.typeBool() + ` NOT NULL ,
  20. PRIMARY KEY (id)
  21. ) ` + db.engine() + `;`)
  22. if err != nil {
  23. t.Rollback()
  24. return err
  25. }
  26. _, err = t.Exec(`CREATE TABLE usersinvited (
  27. invite_id ` + db.typeChar(6) + ` NOT NULL ,
  28. user_id ` + db.typeInt() + ` NOT NULL ,
  29. PRIMARY KEY (invite_id, user_id)
  30. ) ` + db.engine() + `;`)
  31. if err != nil {
  32. t.Rollback()
  33. return err
  34. }
  35. err = t.Commit()
  36. if err != nil {
  37. t.Rollback()
  38. return err
  39. }
  40. return nil
  41. }