20181117121947_legacy_schema.go 818 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package migrations
  2. import (
  3. "database/sql"
  4. "github.com/pressly/goose"
  5. )
  6. func init() {
  7. goose.AddMigration(Up20181117121947, Down20181117121947)
  8. }
  9. func Up20181117121947(tx *sql.Tx) error {
  10. return simpleRun(tx, strings{
  11. `
  12. DROP TABLE IF EXISTS map;
  13. `, `
  14. CREATE TABLE map (
  15. hash bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  16. url varchar(250) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  17. date1 datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  18. date2 datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  19. date3 datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  20. refcount int(11) NOT NULL DEFAULT 0
  21. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  22. `, `
  23. ALTER TABLE map
  24. ADD PRIMARY KEY (hash);
  25. `,
  26. })
  27. }
  28. func Down20181117121947(tx *sql.Tx) error {
  29. return simpleRun(tx, strings{`
  30. DROP TABLE IF EXISTS map;
  31. `})
  32. }