Browse Source

Shop, promo price migration

Vova Tkach 5 years ago
parent
commit
5368a07cec

+ 2 - 1
modules/module_index_act_mysql_setup.go

@@ -323,6 +323,7 @@ func (this *Modules) RegisterAction_IndexMysqlSetup() *Action {
 				currency int(11) NOT NULL COMMENT 'Currency id',
 				currency int(11) NOT NULL COMMENT 'Currency id',
 				price float(8,2) NOT NULL COMMENT 'Product price',
 				price float(8,2) NOT NULL COMMENT 'Product price',
 				price_old float(8,2) NOT NULL DEFAULT '0.00',
 				price_old float(8,2) NOT NULL DEFAULT '0.00',
+				price_promo float(8,2) NOT NULL DEFAULT '0.00',
 				gname varchar(255) NOT NULL,
 				gname varchar(255) NOT NULL,
 				name varchar(255) NOT NULL COMMENT 'Product name',
 				name varchar(255) NOT NULL COMMENT 'Product name',
 				alias varchar(255) NOT NULL COMMENT 'Product alias',
 				alias varchar(255) NOT NULL COMMENT 'Product alias',
@@ -534,7 +535,7 @@ func (this *Modules) RegisterAction_IndexMysqlSetup() *Action {
 			return
 			return
 		}
 		}
 		if _, err = tx.Exec(
 		if _, err = tx.Exec(
-			`INSERT INTO settings (name, value) VALUES ('database_version', '000000019');`,
+			`INSERT INTO settings (name, value) VALUES ('database_version', '000000020');`,
 		); err != nil {
 		); err != nil {
 			tx.Rollback()
 			tx.Rollback()
 			wrap.MsgError(err.Error())
 			wrap.MsgError(err.Error())

+ 1 - 0
support/migrate/000000001.go

@@ -25,4 +25,5 @@ var Migrations = map[string]func(*sqlw.DB, string) error{
 	"000000017": Migrate_000000017,
 	"000000017": Migrate_000000017,
 	"000000018": Migrate_000000018,
 	"000000018": Migrate_000000018,
 	"000000019": Migrate_000000019,
 	"000000019": Migrate_000000019,
+	"000000020": Migrate_000000020,
 }
 }

+ 13 - 0
support/migrate/000000020.go

@@ -0,0 +1,13 @@
+package migrate
+
+import (
+	"golang-fave/engine/sqlw"
+)
+
+func Migrate_000000020(db *sqlw.DB, host string) error {
+	if _, err := db.Exec(`ALTER TABLE shop_products ADD COLUMN price_promo float(8,2) NOT NULL DEFAULT '0.00' AFTER price_old;`); err != nil {
+		return err
+	}
+
+	return nil
+}

+ 1 - 0
support/schema.sql

@@ -129,6 +129,7 @@ CREATE TABLE shop_products (
 	currency int(11) NOT NULL COMMENT 'Currency id',
 	currency int(11) NOT NULL COMMENT 'Currency id',
 	price float(8,2) NOT NULL COMMENT 'Product price',
 	price float(8,2) NOT NULL COMMENT 'Product price',
 	price_old float(8,2) NOT NULL DEFAULT '0.00',
 	price_old float(8,2) NOT NULL DEFAULT '0.00',
+	price_promo float(8,2) NOT NULL DEFAULT '0.00',
 	gname varchar(255) NOT NULL,
 	gname varchar(255) NOT NULL,
 	name varchar(255) NOT NULL COMMENT 'Product name',
 	name varchar(255) NOT NULL COMMENT 'Product name',
 	alias varchar(255) NOT NULL COMMENT 'Product alias',
 	alias varchar(255) NOT NULL COMMENT 'Product alias',