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.
 
 
 
 
 

38 lines
739 B

  1. /*
  2. * Copyright © 2020 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. func optimizeDrafts(db *datastore) error {
  12. t, err := db.Begin()
  13. if err != nil {
  14. t.Rollback()
  15. return err
  16. }
  17. if db.driverName == driverSQLite {
  18. _, err = t.Exec(`CREATE INDEX key_owner_post_id ON posts (owner_id, id)`)
  19. } else {
  20. _, err = t.Exec(`ALTER TABLE posts ADD INDEX(owner_id, id)`)
  21. }
  22. if err != nil {
  23. t.Rollback()
  24. return err
  25. }
  26. err = t.Commit()
  27. if err != nil {
  28. t.Rollback()
  29. return err
  30. }
  31. return nil
  32. }