Skip to content

Commit 9e99b0f

Browse files
committed
[payment] refactor: remove needless product type at adapter layer
- remove them in mariadb repository and 3rd-party processor Signed-off-by: T.H. <7197142+metalalive@users.noreply.github.com>
1 parent 8ebfa8a commit 9e99b0f

31 files changed

+348
-334
lines changed

.github/actions/payment-db/trigger-between-dbs.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SHOW TABLES FROM `test_ecommerce_payment`;
22
SHOW TABLES FROM `test_ecommerce_payment_replica_1`;
33

4-
CREATE DEFINER='DB_USERNAME'@'%' TRIGGER `test_ecommerce_payment`.`rep_insert_chargeline` AFTER INSERT ON `test_ecommerce_payment`.`charge_line` FOR EACH ROW INSERT INTO `test_ecommerce_payment_replica_1`.`charge_line` (`buyer_id`,`create_time`,`store_id`,`product_type`,`product_id`,`amt_orig_unit`,`amt_orig_total`,`qty_orig`,`qty_rej`,`qty_rfnd`,`amt_rfnd_unit`,`amt_rfnd_total`) VALUES (NEW.`buyer_id`, NEW.`create_time`, NEW.`store_id`, NEW.`product_type`, NEW.`product_id`, NEW.`amt_orig_unit`, NEW.`amt_orig_total`, NEW.`qty_orig`, NEW.`qty_rej`, NEW.`qty_rfnd`, NEW.`amt_rfnd_unit`, NEW.`amt_rfnd_total`) ;
4+
CREATE DEFINER='DB_USERNAME'@'%' TRIGGER `test_ecommerce_payment`.`rep_insert_chargeline` AFTER INSERT ON `test_ecommerce_payment`.`charge_line` FOR EACH ROW INSERT INTO `test_ecommerce_payment_replica_1`.`charge_line` (`buyer_id`,`create_time`,`store_id`,`product_id`,`amt_orig_unit`,`amt_orig_total`,`qty_orig`,`qty_rej`,`qty_rfnd`,`amt_rfnd_unit`,`amt_rfnd_total`) VALUES (NEW.`buyer_id`, NEW.`create_time`, NEW.`store_id`, NEW.`product_id`, NEW.`amt_orig_unit`, NEW.`amt_orig_total`, NEW.`qty_orig`, NEW.`qty_rej`, NEW.`qty_rfnd`, NEW.`amt_rfnd_unit`, NEW.`amt_rfnd_total`) ;
55

66

77
SHOW TRIGGERS FROM `test_ecommerce_payment`;

.github/workflows/payment-ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ jobs:
7575
- name: run database schema migration
7676
working-directory: services/payment
7777
run: |
78-
liquibase --changeLogFile=./migrations/changelog_payment_primary.xml \
78+
liquibase --changeLogFile=./migrations/changelog_primary-root.xml \
7979
--url=jdbc:mariadb://localhost:3307/test_ecommerce_payment \
8080
--username=DB_USERNAME --password=DB_PASSWORD --log-level=info update
81-
liquibase --changeLogFile=./migrations/changelog_payment_replica.xml \
81+
liquibase --changeLogFile=./migrations/changelog_replica.xml \
8282
--url=jdbc:mariadb://localhost:3307/test_ecommerce_payment_replica_1 \
8383
--username=DB_USERNAME --password=DB_PASSWORD --log-level=info update
8484

services/payment/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ If you configure SQL database as the datastore destination in the development se
2121
```shell
2222
> cd ${SERVICE_BASE_PATH}
2323
> /PATH/TO/liquibase --defaults-file=/liquibase.properties \
24-
--changeLogFile=./migration/changelog_payment_primary.xml \
24+
--changeLogFile=./migrations/changelog_primary-root.xml \
2525
--url=jdbc:mariadb://$HOST:$PORT/$DB_NAME --username=$USER --password=$PASSWORD \
2626
--log-level=info update
2727

2828
> /PATH/TO/liquibase --defaults-file=/liquibase.properties \
29-
--changeLogFile=./migration/changelog_payment_replica.xml \
29+
--changeLogFile=./migrations/changelog_replica.xml \
3030
--url=jdbc:mariadb://$HOST:$PORT/$DB_NAME --username=$USER --password=$PASSWORD \
3131
--log-level=info update
3232

3333
> /PATH/TO/liquibase --defaults-file=./liquibase.properties \
34-
--changeLogFile=./migration/changelog_order.xml \
34+
--changeLogFile=./migrations/changelog_primary-root.xml \
3535
--url=jdbc:mariadb://$HOST:$PORT/$DB_NAME --username=$USER --password=$PASSWORD \
3636
--log-level=info rollback $VERSION_TAG
3737
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
6+
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
7+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
8+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
9+
http://www.liquibase.org/xml/ns/dbchangelog-ext
10+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
11+
http://www.liquibase.org/xml/ns/pro
12+
http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
13+
14+
<include file="./migrations/changelog_primary-v0.0.xml"/>
15+
<include file="./migrations/changelog_primary-v0.1.xml"/>
16+
</databaseChangeLog>

services/payment/migrations/changelog_payment_primary.xml renamed to services/payment/migrations/changelog_primary-v0.0.xml

File renamed without changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd
7+
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd ">
8+
<changeSet id="tag_version_0.1.0" author="Haam">
9+
<tagDatabase tag="0.1.0" />
10+
</changeSet>
11+
<changeSet id="discard_prodtype__oline_detail" author="T.H.">
12+
<comment> </comment>
13+
<sql dbms="mariadb">
14+
ALTER TABLE `order_line_detail` DROP PRIMARY KEY;
15+
ALTER TABLE `order_line_detail` DROP COLUMN `product_type`;
16+
ALTER TABLE `order_line_detail` ADD PRIMARY KEY (`o_id`,`store_id`,`product_id`);
17+
</sql>
18+
<rollback>
19+
ALTER TABLE `order_line_detail` DROP PRIMARY KEY;
20+
ALTER TABLE `order_line_detail` ADD COLUMN `product_type` enum('1','2') DEFAULT '1';
21+
ALTER TABLE `order_line_detail` ADD PRIMARY KEY (`o_id`,`store_id`,`product_type`,`product_id`);
22+
</rollback>
23+
</changeSet>
24+
<changeSet id="discard_prodtype__oline_refund_req" author="T.H.">
25+
<comment> </comment>
26+
<sql dbms="mariadb">
27+
ALTER TABLE `oline_refund_req` DROP PRIMARY KEY;
28+
ALTER TABLE `oline_refund_req` DROP COLUMN `product_type`;
29+
ALTER TABLE `oline_refund_req` ADD PRIMARY KEY (`o_id`,`store_id`,`product_id`,`create_time`);
30+
</sql>
31+
<rollback>
32+
ALTER TABLE `oline_refund_req` DROP PRIMARY KEY;
33+
ALTER TABLE `oline_refund_req` ADD COLUMN `product_type` enum('1','2') DEFAULT '1';
34+
ALTER TABLE `oline_refund_req` ADD PRIMARY KEY (`o_id`,`store_id`,`product_type`,`product_id`,`create_time`);
35+
</rollback>
36+
</changeSet>
37+
<changeSet id="discard_prodtype__charge_line" author="T.H.">
38+
<comment> </comment>
39+
<sql dbms="mariadb">
40+
ALTER TABLE `charge_line` DROP FOREIGN KEY `c_fk_charge_buyer_toplvl_id_0`;
41+
ALTER TABLE `charge_line` DROP PRIMARY KEY;
42+
ALTER TABLE `charge_line` DROP COLUMN `product_type`;
43+
ALTER TABLE `charge_line` ADD PRIMARY KEY (`buyer_id`,`create_time`,`store_id`,`product_id`);
44+
ALTER TABLE `charge_line` ADD CONSTRAINT `c_fk_charge_buyer_toplvl_id_0` FOREIGN KEY (`buyer_id`, `create_time`) REFERENCES `charge_buyer_toplvl` (`usr_id`, `create_time`) ON DELETE CASCADE ON UPDATE CASCADE;
45+
</sql>
46+
<rollback>
47+
ALTER TABLE `charge_line` DROP FOREIGN KEY `c_fk_charge_buyer_toplvl_id_0`;
48+
ALTER TABLE `charge_line` DROP PRIMARY KEY;
49+
ALTER TABLE `charge_line` ADD COLUMN `product_type` enum('1','2') DEFAULT '1';
50+
ALTER TABLE `charge_line` ADD PRIMARY KEY (`buyer_id`,`create_time`,`store_id`,`product_type`,`product_id`);
51+
ALTER TABLE `charge_line` ADD CONSTRAINT `c_fk_charge_buyer_toplvl_id_0` FOREIGN KEY (`buyer_id`, `create_time`) REFERENCES `charge_buyer_toplvl` (`usr_id`, `create_time`) ON DELETE CASCADE ON UPDATE CASCADE;
52+
</rollback>
53+
</changeSet>
54+
55+
<changeSet id="tag_version_0.1.1" author="Haam">
56+
<tagDatabase tag="0.1.1" />
57+
</changeSet>
58+
</databaseChangeLog>

services/payment/migrations/changelog_payment_replica.xml renamed to services/payment/migrations/changelog_replica.xml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,27 @@
4848
DROP INDEX `by_merchant` ON `charge_line` ;
4949
</rollback>
5050
</changeSet>
51-
5251
<changeSet id="tag_version_0.0.2" author="T.H." labels="payment">
5352
<tagDatabase tag="0.0.2" />
5453
</changeSet>
54+
<changeSet id="tag_version_0.1.0" author="T.H." labels="payment">
55+
<tagDatabase tag="0.1.0" />
56+
</changeSet>
57+
<changeSet id="discard_prodtype__charge_line" author="T.H.">
58+
<comment> </comment>
59+
<sql dbms="mariadb">
60+
ALTER TABLE `charge_line` DROP PRIMARY KEY;
61+
ALTER TABLE `charge_line` DROP COLUMN `product_type`;
62+
ALTER TABLE `charge_line` ADD PRIMARY KEY (`buyer_id`,`create_time`,`store_id`,`product_id`);
63+
</sql>
64+
<rollback>
65+
ALTER TABLE `charge_line` DROP PRIMARY KEY;
66+
ALTER TABLE `charge_line` ADD COLUMN `product_type` enum('1','2') DEFAULT '1';
67+
ALTER TABLE `charge_line` ADD PRIMARY KEY (`buyer_id`,`create_time`,`store_id`,`product_type`,`product_id`);
68+
</rollback>
69+
</changeSet>
70+
71+
<changeSet id="tag_version_0.1.1" author="T.H." labels="payment">
72+
<tagDatabase tag="0.1.1" />
73+
</changeSet>
5574
</databaseChangeLog>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
CREATE DEFINER='app-user'@'localhost' TRIGGER `test_ecommerce_payment`.`rep_insert_chargeline` AFTER INSERT ON `test_ecommerce_payment`.`charge_line` FOR EACH ROW INSERT INTO `test_ecommerce_payment_replica_1`.`charge_line` (`buyer_id`,`create_time`,`store_id`,`product_type`,`product_id`,`amt_orig_unit`,`amt_orig_total`,`qty_orig`,`qty_rej`,`qty_rfnd`,`amt_rfnd_unit`,`amt_rfnd_total`) VALUES (NEW.`buyer_id`, NEW.`create_time`, NEW.`store_id`, NEW.`product_type`, NEW.`product_id`, NEW.`amt_orig_unit`, NEW.`amt_orig_total`, NEW.`qty_orig`, NEW.`qty_rej`, NEW.`qty_rfnd`, NEW.`amt_rfnd_unit`, NEW.`amt_rfnd_total`) ;
2+
CREATE DEFINER='app-user'@'localhost' TRIGGER `test_ecommerce_payment`.`rep_insert_chargeline` AFTER INSERT ON `test_ecommerce_payment`.`charge_line` FOR EACH ROW INSERT INTO `test_ecommerce_payment_replica_1`.`charge_line` (`buyer_id`,`create_time`,`store_id`,`product_id`,`amt_orig_unit`,`amt_orig_total`,`qty_orig`,`qty_rej`,`qty_rfnd`,`amt_rfnd_unit`,`amt_rfnd_total`) VALUES (NEW.`buyer_id`, NEW.`create_time`, NEW.`store_id`, NEW.`product_id`, NEW.`amt_orig_unit`, NEW.`amt_orig_total`, NEW.`qty_orig`, NEW.`qty_rej`, NEW.`qty_rfnd`, NEW.`amt_rfnd_unit`, NEW.`amt_rfnd_total`) ;
33

4-
CREATE DEFINER='app-user'@'localhost' TRIGGER `ecommerce_payment`.`rep_insert_chargeline` AFTER INSERT ON `ecommerce_payment`.`charge_line` FOR EACH ROW INSERT INTO `ecommerce_payment_replica_1`.`charge_line` (`buyer_id`,`create_time`,`store_id`,`product_type`,`product_id`,`amt_orig_unit`,`amt_orig_total`,`qty_orig`,`qty_rej`,`qty_rfnd`,`amt_rfnd_unit`,`amt_rfnd_total`) VALUES (NEW.`buyer_id`, NEW.`create_time`, NEW.`store_id`, NEW.`product_type`, NEW.`product_id`, NEW.`amt_orig_unit`, NEW.`amt_orig_total`, NEW.`qty_orig`, NEW.`qty_rej`, NEW.`qty_rfnd`, NEW.`amt_rfnd_unit`, NEW.`amt_rfnd_total`) ;
4+
CREATE DEFINER='app-user'@'localhost' TRIGGER `ecommerce_payment`.`rep_insert_chargeline` AFTER INSERT ON `ecommerce_payment`.`charge_line` FOR EACH ROW INSERT INTO `ecommerce_payment_replica_1`.`charge_line` (`buyer_id`,`create_time`,`store_id`,`product_id`,`amt_orig_unit`,`amt_orig_total`,`qty_orig`,`qty_rej`,`qty_rfnd`,`amt_rfnd_unit`,`amt_rfnd_total`) VALUES (NEW.`buyer_id`, NEW.`create_time`, NEW.`store_id`, NEW.`product_id`, NEW.`amt_orig_unit`, NEW.`amt_orig_total`, NEW.`qty_orig`, NEW.`qty_rej`, NEW.`qty_rfnd`, NEW.`amt_rfnd_unit`, NEW.`amt_rfnd_total`) ;
55

services/payment/settings/development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"port": 8015,
6767
"host":"localhost",
6868
"max_failures": 3,
69-
"api_version": "0.0.8",
69+
"api_version": "0.1.0",
7070
"max_connections": 127,
7171
"cors": "common/data/cors.json",
7272
"routes": [

services/payment/settings/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"port": 8016,
5757
"host":"localhost",
5858
"max_failures": 3,
59-
"api_version": "0.0.8",
59+
"api_version": "0.1.0",
6060
"max_connections": 129,
6161
"cors": "common/data/cors.json",
6262
"routes": [

0 commit comments

Comments
 (0)