Skip to content

Commit

Permalink
change mysql schema folder v57 to v8 (cadence-workflow#5356)
Browse files Browse the repository at this point in the history
* change mysql schema folder v57 to v8

* add a string in CONTRIBUTING
  • Loading branch information
bowenxia authored Jul 21, 2023
1 parent 25e69ba commit 15f7fea
Show file tree
Hide file tree
Showing 38 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ docker-compose -f ./docker/dev/cassandra.yml up -d
```
Also use `docker-compose -f ./docker/dev/cassandra.yml down` to stop and clean up the resources.

* Alternatively, use `./docker/dev/mysql.yml` for MySQL dependency
* Alternatively, use `./docker/dev/mysql.yml` for MySQL dependency. (MySQL has been updated from 5.7 to 8.0)
* Alternatively, use `./docker/dev/postgres.yml` for PostgreSQL dependency
* Alternatively, use `./docker/dev/cassandra-esv7-kafka.yml` for Cassandra, ElasticSearch(v7) and Kafka/ZooKeeper dependencies
* Alternatively, use `./docker/dev/mysql-esv7-kafka.yml` for MySQL, ElasticSearch(v7) and Kafka/ZooKeeper dependencies
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -609,24 +609,24 @@ install-schema: cadence-cassandra-tool
install-schema-mysql: cadence-sql-tool
./cadence-sql-tool --user root --pw cadence create --db cadence
./cadence-sql-tool --user root --pw cadence --db cadence setup-schema -v 0.0
./cadence-sql-tool --user root --pw cadence --db cadence update-schema -d ./schema/mysql/v57/cadence/versioned
./cadence-sql-tool --user root --pw cadence --db cadence update-schema -d ./schema/mysql/v8/cadence/versioned
./cadence-sql-tool --user root --pw cadence create --db cadence_visibility
./cadence-sql-tool --user root --pw cadence --db cadence_visibility setup-schema -v 0.0
./cadence-sql-tool --user root --pw cadence --db cadence_visibility update-schema -d ./schema/mysql/v57/visibility/versioned
./cadence-sql-tool --user root --pw cadence --db cadence_visibility update-schema -d ./schema/mysql/v8/visibility/versioned

install-schema-multiple-mysql: cadence-sql-tool install-schema-es-v7
./cadence-sql-tool --user root --pw cadence create --db cadence0
./cadence-sql-tool --user root --pw cadence --db cadence0 setup-schema -v 0.0
./cadence-sql-tool --user root --pw cadence --db cadence0 update-schema -d ./schema/mysql/v57/cadence/versioned
./cadence-sql-tool --user root --pw cadence --db cadence0 update-schema -d ./schema/mysql/v8/cadence/versioned
./cadence-sql-tool --user root --pw cadence create --db cadence1
./cadence-sql-tool --user root --pw cadence --db cadence1 setup-schema -v 0.0
./cadence-sql-tool --user root --pw cadence --db cadence1 update-schema -d ./schema/mysql/v57/cadence/versioned
./cadence-sql-tool --user root --pw cadence --db cadence1 update-schema -d ./schema/mysql/v8/cadence/versioned
./cadence-sql-tool --user root --pw cadence create --db cadence2
./cadence-sql-tool --user root --pw cadence --db cadence2 setup-schema -v 0.0
./cadence-sql-tool --user root --pw cadence --db cadence2 update-schema -d ./schema/mysql/v57/cadence/versioned
./cadence-sql-tool --user root --pw cadence --db cadence2 update-schema -d ./schema/mysql/v8/cadence/versioned
./cadence-sql-tool --user root --pw cadence create --db cadence3
./cadence-sql-tool --user root --pw cadence --db cadence3 setup-schema -v 0.0
./cadence-sql-tool --user root --pw cadence --db cadence3 update-schema -d ./schema/mysql/v57/cadence/versioned
./cadence-sql-tool --user root --pw cadence --db cadence3 update-schema -d ./schema/mysql/v8/cadence/versioned

install-schema-postgres: cadence-sql-tool
./cadence-sql-tool -p 5432 -u postgres -pw cadence --pl postgres create --db cadence
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/sql/sqlplugin/mysql/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func sanitizeAttr(inkey string, invalue string) (string, string) {
}

const (
testSchemaDir = "schema/mysql/v57"
testSchemaDir = "schema/mysql/v8"
)

// GetTestClusterOption return test options
Expand Down
4 changes: 2 additions & 2 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ setup_cassandra_schema() {
}

setup_mysql_schema() {
SCHEMA_DIR=$CADENCE_HOME/schema/mysql/v57/cadence/versioned
SCHEMA_DIR=$CADENCE_HOME/schema/mysql/v8/cadence/versioned
if [ "$MYSQL_TX_ISOLATION_COMPAT" == "true" ]; then
CONNECT_ATTR='--connect-attributes tx_isolation=READ-COMMITTED'
fi
cadence-sql-tool --ep $MYSQL_SEEDS -u $MYSQL_USER --pw $MYSQL_PWD $CONNECT_ATTR create --db $DBNAME
cadence-sql-tool --ep $MYSQL_SEEDS -u $MYSQL_USER --pw $MYSQL_PWD $CONNECT_ATTR --db $DBNAME setup-schema -v 0.0
cadence-sql-tool --ep $MYSQL_SEEDS -u $MYSQL_USER --pw $MYSQL_PWD $CONNECT_ATTR --db $DBNAME update-schema -d $SCHEMA_DIR
VISIBILITY_SCHEMA_DIR=$CADENCE_HOME/schema/mysql/v57/visibility/versioned
VISIBILITY_SCHEMA_DIR=$CADENCE_HOME/schema/mysql/v8/visibility/versioned
cadence-sql-tool --ep $MYSQL_SEEDS -u $MYSQL_USER --pw $MYSQL_PWD $CONNECT_ATTR create --db $VISIBILITY_DBNAME
cadence-sql-tool --ep $MYSQL_SEEDS -u $MYSQL_USER --pw $MYSQL_PWD --db $VISIBILITY_DBNAME $CONNECT_ATTR setup-schema -v 0.0
cadence-sql-tool --ep $MYSQL_SEEDS -u $MYSQL_USER --pw $MYSQL_PWD --db $VISIBILITY_DBNAME $CONNECT_ATTR update-schema -d $VISIBILITY_SCHEMA_DIR
Expand Down
2 changes: 1 addition & 1 deletion docs/persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ This interface is tied to a specific schema i.e. the way data is laid out across
names themselves are fixed. However, you get the flexibility wrt how you store the data within a table (i.e. column names and
types are not fixed). The API interface can be found [here](https://github.com/uber/cadence/blob/master/common/persistence/sql/plugins/interfaces.go).
It's basically a CRUD API for every table in the schema. A sample schema definition for mysql that uses this interface
can be found [here](https://github.com/uber/cadence/blob/master/schema/mysql/v57/cadence/schema.sql)
can be found [here](https://github.com/uber/cadence/blob/master/schema/mysql/v8/cadence/schema.sql)

Any database that supports this interface can be plugged in with cadence server.
We have implemented Postgres within the repo, and also here is [**an example**](https://github.com/longquanzheng/cadence-extensions/tree/master/cadence-sqlite) to implement any database externally.
Expand Down
2 changes: 1 addition & 1 deletion schema/mysql/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ package mysql

import "embed"

//go:embed v57/cadence/* v57/visibility/*
//go:embed v8/cadence/* v8/visibility/*
var SchemaFS embed.FS
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tools/common/schema/updatetask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ func (s *UpdateTaskTestSuite) TestReadSchemaDirFromEmbeddings() {
s.NoError(err)
s.Equal([]string{"v0.7", "v0.8", "v0.9"}, ans)

fsys, err = fs.Sub(mysql.SchemaFS, "v57/cadence/versioned")
fsys, err = fs.Sub(mysql.SchemaFS, "v8/cadence/versioned")
s.NoError(err)
ans, err = readSchemaDir(fsys, "0.3", "")
s.NoError(err)
s.Equal([]string{"v0.4", "v0.5"}, ans)

fsys, err = fs.Sub(mysql.SchemaFS, "v57/visibility/versioned")
fsys, err = fs.Sub(mysql.SchemaFS, "v8/visibility/versioned")
s.NoError(err)
ans, err = readSchemaDir(fsys, "0.5", "")
s.NoError(err)
Expand Down
12 changes: 6 additions & 6 deletions tools/sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ SQL_USER=$USERNAME SQL_PASSWORD=$PASSWD make install-schema-mysql

```
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence setup-schema -v 0.0 -- this sets up just the schema version tables with initial version of 0.0
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence update-schema -d ./schema/mysql/v57/cadence/versioned -- upgrades your schema to the latest version
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence update-schema -d ./schema/mysql/v8/cadence/versioned -- upgrades your schema to the latest version
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility setup-schema -v 0.0 -- this sets up just the schema version tables with initial version of 0.0 for visibility
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility update-schema -d ./schema/mysql/v57/visibility/versioned -- upgrades your schema to the latest version for visibility
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility update-schema -d ./schema/mysql/v8/visibility/versioned -- upgrades your schema to the latest version for visibility
```

### Update schema as part of a release
You can only upgrade to a new version after the initial setup done above.

```
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence update-schema -d ./schema/mysql/v57/cadence/versioned -v x.x --dryrun -- executes a dryrun of upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence update-schema -d ./schema/mysql/v57/cadence/versioned -v x.x -- actually executes the upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence update-schema -d ./schema/mysql/v8/cadence/versioned -v x.x --dryrun -- executes a dryrun of upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence update-schema -d ./schema/mysql/v8/cadence/versioned -v x.x -- actually executes the upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility update-schema -d ./schema/mysql/v57/cadence/versioned -v x.x --dryrun -- executes a dryrun of upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility update-schema -d ./schema/mysql/v57/cadence/versioned -v x.x -- actually executes the upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility update-schema -d ./schema/mysql/v8/cadence/versioned -v x.x --dryrun -- executes a dryrun of upgrade to version x.x
./cadence-sql-tool --ep $SQL_HOST_ADDR -p $port --plugin mysql --db cadence_visibility update-schema -d ./schema/mysql/v8/cadence/versioned -v x.x -- actually executes the upgrade to version x.x
```

4 changes: 2 additions & 2 deletions tools/sql/clitest/updatetaskTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *UpdateSchemaTestSuite) TestDryrun() {
conn, err := newTestConn(s.DBName, s.pluginName)
s.Nil(err)
defer conn.Close()
dir := "../../../schema/mysql/v57/cadence/versioned"
dir := "../../../schema/mysql/v8/cadence/versioned"
s.RunDryrunTest(sql.BuildCLIOptions(), conn, "--db", dir, mysql.Version)
}

Expand All @@ -82,6 +82,6 @@ func (s *UpdateSchemaTestSuite) TestVisibilityDryrun() {
conn, err := newTestConn(s.DBName, s.pluginName)
s.Nil(err)
defer conn.Close()
dir := "../../../schema/mysql/v57/visibility/versioned"
dir := "../../../schema/mysql/v8/visibility/versioned"
s.RunDryrunTest(sql.BuildCLIOptions(), conn, "--db", dir, mysql.VisibilityVersion)
}
4 changes: 2 additions & 2 deletions tools/sql/clitest/versionTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (s *VersionTestSuite) TestVerifyCompatibleVersion() {
_, filename, _, ok := runtime.Caller(0)
s.True(ok)
root := path.Dir(path.Dir(path.Dir(path.Dir(filename))))
sqlFile := path.Join(root, "schema/mysql/v57/cadence/schema.sql")
visSQLFile := path.Join(root, "schema/mysql/v57/visibility/schema.sql")
sqlFile := path.Join(root, "schema/mysql/v8/cadence/schema.sql")
visSQLFile := path.Join(root, "schema/mysql/v8/visibility/schema.sql")

defer s.createDatabase(database)()
defer s.createDatabase(visDatabase)()
Expand Down

0 comments on commit 15f7fea

Please sign in to comment.