000000011.go 560 B

1234567891011121314151617181920212223
  1. package migrate
  2. import (
  3. "context"
  4. "golang-fave/engine/sqlw"
  5. )
  6. func Migrate_000000011(ctx context.Context, db *sqlw.DB, host string) error {
  7. if _, err := db.Exec(ctx, `ALTER TABLE shop_product_images ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;`); err != nil {
  8. return err
  9. }
  10. if _, err := db.Exec(ctx, `ALTER TABLE shop_product_images ADD COLUMN ord INT(11) NOT NULL DEFAULT 0 AFTER filename;`); err != nil {
  11. return err
  12. }
  13. if _, err := db.Exec(ctx, `UPDATE shop_product_images SET ord = id;`); err != nil {
  14. return err
  15. }
  16. return nil
  17. }