migrations.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package migrations
  2. import "time"
  3. // Id int64
  4. // Login string `xorm:"UNIQUE NOT NULL"`
  5. // Email string `xorm:"UNIQUE NOT NULL"`
  6. // Name string
  7. // FullName string
  8. // Password string
  9. // IsAdmin bool
  10. // Salt string `xorm:"VARCHAR(10)"`
  11. // Company string
  12. // NextDashboardId int
  13. // UsingAccountId int64
  14. // Created time.Time
  15. // Updated time.Time
  16. func AddMigrations(mg *Migrator) {
  17. // TABLE Account
  18. // -------------------------------
  19. mg.AddMigration("create account table", new(RawSqlMigration).
  20. Sqlite(`
  21. CREATE TABLE account (
  22. id INTEGER PRIMARY KEY AUTOINCREMENT,
  23. login TEXT NOT NULL,
  24. email TEXT NOT NULL
  25. )
  26. `).
  27. Mysql(`
  28. CREATE TABLE account (
  29. id BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id),
  30. login VARCHAR(255) NOT NULL,
  31. email VARCHAR(255) NOT NULL
  32. )
  33. `))
  34. // ------------------------------
  35. mg.AddMigration("add index UIX_account.login", new(AddIndexMigration).
  36. Name("UIX_account_login").Table("account").Columns("login"))
  37. // ------------------------------
  38. mg.AddMigration("add column", new(AddColumnMigration).
  39. Table("account").Column("name").Type(DB_TYPE_STRING).Length(255))
  40. }
  41. type MigrationLog struct {
  42. Id int64
  43. MigrationId string
  44. Sql string
  45. Success bool
  46. Error string
  47. Timestamp time.Time
  48. }