@@ -45,12 +45,18 @@ import (
45
45
// default collation as it has to work across versions and the 8.0 default does not exist in 5.7.
46
46
var (
47
47
// All standard user tables should have a primary key and at least one secondary key.
48
- customerTypes = []string {"'individual'" , "'soho'" , "'enterprise'" }
48
+ customerTypes = []string {"'individual'" , "'soho'" , "'enterprise'" }
49
+ customerTableTemplate = `create table customer(cid int auto_increment, name varchar(128) collate utf8mb4_bin, meta json default null,
50
+ industryCategory varchar(100) generated always as (json_extract(meta, _utf8mb4'$.industry')) virtual, typ enum(%s),
51
+ sport set('football','cricket','baseball'), ts timestamp not null default current_timestamp, bits bit(2) default b'11', date1 datetime not null default '0000-00-00 00:00:00',
52
+ date2 datetime not null default '2021-00-01 00:00:00', dec80 decimal(8,0), blb blob, primary key(%s), key(name)) CHARSET=utf8mb4`
53
+ customerTable = fmt .Sprintf (customerTableTemplate , strings .Join (customerTypes , "," ), "cid,typ" /* PK columns */ )
54
+ // customerTableModifiedPK has a PK on (cid) vs (cid,typ).
55
+ customerTableModifiedPK = fmt .Sprintf (customerTableTemplate , strings .Join (customerTypes , "," ), "cid" /* PK columns */ )
56
+
49
57
initialProductSchema = fmt .Sprintf (`
50
58
create table product(pid int, description varbinary(128), date1 datetime not null default '0000-00-00 00:00:00', date2 datetime not null default '2021-00-01 00:00:00', primary key(pid), key(date1,date2)) CHARSET=utf8mb4;
51
- create table customer(cid int auto_increment, name varchar(128) collate utf8mb4_bin, meta json default null, industryCategory varchar(100) generated always as (json_extract(meta, _utf8mb4'$.industry')) virtual,
52
- typ enum(%s), sport set('football','cricket','baseball'), ts timestamp not null default current_timestamp, bits bit(2) default b'11', date1 datetime not null default '0000-00-00 00:00:00',
53
- date2 datetime not null default '2021-00-01 00:00:00', dec80 decimal(8,0), blb blob, primary key(cid,typ), key(name)) CHARSET=utf8mb4;
59
+ %s;
54
60
create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
55
61
create table merchant(mname varchar(128), category varchar(128), primary key(mname), key(category)) CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
56
62
create table orders(oid int, cid int, pid int, mname varchar(128), price int, qty int, total int as (qty * price), total2 int as (qty * price) stored, primary key(oid), key(pid), key(cid)) CHARSET=utf8;
@@ -69,7 +75,8 @@ create table `+"`blüb_tbl`"+` (id int, val1 varchar(20), `+"`blöb1`"+` blob,
69
75
create table reftable (id int, val1 varchar(20), primary key(id), key(val1));
70
76
create table loadtest (id int, name varchar(256), primary key(id), key(name));
71
77
create table nopk (name varchar(128), age int unsigned);
72
- ` , strings .Join (customerTypes , "," ))
78
+ ` , customerTable )
79
+
73
80
// These should always be ignored in vreplication
74
81
internalSchema = `
75
82
create table _1e275eef_3b20_11eb_a38f_04ed332e05c2_20201210204529_gho(id int, val varbinary(128), primary key(id));
0 commit comments