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.
 
 
 
 
 

67 lines
1.2 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. import (
  12. "fmt"
  13. )
  14. // TODO: use now() from writefreely pkg
  15. func (db *datastore) now() string {
  16. if db.driverName == driverSQLite {
  17. return "strftime('%Y-%m-%d %H:%M:%S','now')"
  18. }
  19. return "NOW()"
  20. }
  21. func (db *datastore) typeInt() string {
  22. if db.driverName == driverSQLite {
  23. return "INTEGER"
  24. }
  25. return "INT"
  26. }
  27. func (db *datastore) typeSmallInt() string {
  28. if db.driverName == driverSQLite {
  29. return "INTEGER"
  30. }
  31. return "SMALLINT"
  32. }
  33. func (db *datastore) typeText() string {
  34. return "TEXT"
  35. }
  36. func (db *datastore) typeChar(l int) string {
  37. if db.driverName == driverSQLite {
  38. return "TEXT"
  39. }
  40. return fmt.Sprintf("CHAR(%d)", l)
  41. }
  42. func (db *datastore) typeBool() string {
  43. if db.driverName == driverSQLite {
  44. return "INTEGER"
  45. }
  46. return "TINYINT(1)"
  47. }
  48. func (db *datastore) typeDateTime() string {
  49. return "DATETIME"
  50. }
  51. func (db *datastore) engine() string {
  52. if db.driverName == driverSQLite {
  53. return ""
  54. }
  55. return " ENGINE = InnoDB"
  56. }