Fix migration scripts (#18756)
* Fix migration scripts Set the DB schema version in DB prior to running migration https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=c2525dbb-23eb-4fe7-8fb4-e9a5f503dc8c ```release-note NONE ``` * Revert schema to 6.0.0 and update CI scripts * Fix typo * Add missing default * Fix extra comma Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
078fdd8422
Коммит
acd08f0a48
@@ -71,7 +71,7 @@ CREATE TABLE `ChannelMemberHistory` (
|
||||
CREATE TABLE `ChannelMembers` (
|
||||
`ChannelId` varchar(26) NOT NULL,
|
||||
`UserId` varchar(26) NOT NULL,
|
||||
`Roles` text DEFAULT NULL,
|
||||
`Roles` varchar(64) DEFAULT NULL,
|
||||
`LastViewedAt` bigint(20) DEFAULT NULL,
|
||||
`MsgCount` bigint(20) DEFAULT NULL,
|
||||
`MentionCount` bigint(20) DEFAULT NULL,
|
||||
@@ -106,7 +106,6 @@ CREATE TABLE `Channels` (
|
||||
`Header` text,
|
||||
`Purpose` varchar(250) DEFAULT NULL,
|
||||
`LastPostAt` bigint(20) DEFAULT NULL,
|
||||
`LastRootPostAt` bigint(20) DEFAULT NULL,
|
||||
`TotalMsgCount` bigint(20) DEFAULT NULL,
|
||||
`ExtraUpdateAt` bigint(20) DEFAULT NULL,
|
||||
`CreatorId` varchar(26) DEFAULT NULL,
|
||||
@@ -768,7 +767,7 @@ CREATE TABLE `Sessions` (
|
||||
`LastActivityAt` bigint(20) DEFAULT NULL,
|
||||
`UserId` varchar(26) DEFAULT NULL,
|
||||
`DeviceId` text,
|
||||
`Roles` text DEFAULT NULL,
|
||||
`Roles` varchar(64) DEFAULT NULL,
|
||||
`IsOAuth` tinyint(1) DEFAULT NULL,
|
||||
`ExpiredNotify` tinyint(1) DEFAULT NULL,
|
||||
`Props` json DEFAULT NULL,
|
||||
@@ -938,7 +937,7 @@ CREATE TABLE `Systems` (
|
||||
CREATE TABLE `TeamMembers` (
|
||||
`TeamId` varchar(26) NOT NULL,
|
||||
`UserId` varchar(26) NOT NULL,
|
||||
`Roles` text DEFAULT NULL,
|
||||
`Roles` varchar(64) DEFAULT NULL,
|
||||
`DeleteAt` bigint(20) DEFAULT NULL,
|
||||
`SchemeUser` tinyint(4) DEFAULT NULL,
|
||||
`SchemeAdmin` tinyint(4) DEFAULT NULL,
|
||||
@@ -73,7 +73,7 @@ ALTER TABLE public.channelmemberhistory OWNER TO mmuser;
|
||||
CREATE TABLE public.channelmembers (
|
||||
channelid character varying(26) NOT NULL,
|
||||
userid character varying(26) NOT NULL,
|
||||
roles character varying(256),
|
||||
roles character varying(64),
|
||||
lastviewedat bigint,
|
||||
msgcount bigint,
|
||||
mentioncount bigint,
|
||||
@@ -105,14 +105,14 @@ CREATE TABLE public.channels (
|
||||
header character varying(1024),
|
||||
purpose character varying(250),
|
||||
lastpostat bigint,
|
||||
lastrootpostat bigint,
|
||||
totalmsgcount bigint,
|
||||
extraupdateat bigint,
|
||||
creatorid character varying(26),
|
||||
schemeid character varying(26),
|
||||
groupconstrained boolean,
|
||||
shared boolean,
|
||||
totalmsgcountroot bigint
|
||||
totalmsgcountroot bigint,
|
||||
lastrootpostat bigint DEFAULT '0'::bigint
|
||||
);
|
||||
|
||||
|
||||
@@ -676,7 +676,7 @@ CREATE TABLE public.sessions (
|
||||
lastactivityat bigint,
|
||||
userid character varying(26),
|
||||
deviceid character varying(512),
|
||||
roles character varying(256),
|
||||
roles character varying(64),
|
||||
isoauth boolean,
|
||||
expirednotify boolean,
|
||||
props jsonb
|
||||
@@ -826,7 +826,7 @@ ALTER TABLE public.systems OWNER TO mmuser;
|
||||
CREATE TABLE public.teammembers (
|
||||
teamid character varying(26) NOT NULL,
|
||||
userid character varying(26) NOT NULL,
|
||||
roles character varying(256),
|
||||
roles character varying(64),
|
||||
deleteat bigint,
|
||||
schemeuser boolean,
|
||||
schemeadmin boolean,
|
||||
@@ -10,6 +10,8 @@ docker exec mattermost-mysql mysql -uroot -pmostest -e "CREATE DATABASE migrated
|
||||
echo "Importing mysql dump from version ${SCHEMA_VERSION}"
|
||||
docker exec -i mattermost-mysql mysql -D migrated -uroot -pmostest < $(pwd)/scripts/mattermost-mysql-$SCHEMA_VERSION.sql
|
||||
|
||||
docker exec -i mattermost-mysql mysql -D migrated -uroot -pmostest -e "INSERT INTO Systems (Name, Value) VALUES ('Version', '$SCHEMA_VERSION')"
|
||||
|
||||
echo "Setting up config for db migration"
|
||||
cat config/config.json | \
|
||||
jq '.SqlSettings.DataSource = "mmuser:mostest@tcp(localhost:3306)/migrated?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"' | \
|
||||
@@ -26,7 +28,7 @@ cat config/config.json | \
|
||||
echo "Setting up fresh db"
|
||||
make ARGS="version --config $TMPDIR/config.json" run-cli
|
||||
|
||||
if [ "$SCHEMA_VERSION" == "5.0" ]; then
|
||||
if [ "$SCHEMA_VERSION" == "5.0.0" ]; then
|
||||
for i in "ChannelMembers SchemeGuest" "ChannelMembers MsgCountRoot" "ChannelMembers MentionCountRoot" "Channels TotalMsgCountRoot"; do
|
||||
a=( $i );
|
||||
echo "Ignoring known MySQL mismatch: ${a[0]}.${a[1]}"
|
||||
|
||||
@@ -10,6 +10,8 @@ docker exec mattermost-postgres sh -c 'exec echo "CREATE DATABASE migrated; CREA
|
||||
echo "Importing postgres dump from version ${SCHEMA_VERSION}"
|
||||
docker exec -i mattermost-postgres psql -U mmuser -d migrated < $(pwd)/scripts/mattermost-postgresql-$SCHEMA_VERSION.sql
|
||||
|
||||
docker exec -i mattermost-postgres psql -U mmuser -d migrated -c "INSERT INTO Systems (Name, Value) VALUES ('Version', '$SCHEMA_VERSION')"
|
||||
|
||||
echo "Setting up config for db migration"
|
||||
cat config/config.json | \
|
||||
jq '.SqlSettings.DataSource = "postgres://mmuser:mostest@localhost:5432/migrated?sslmode=disable&connect_timeout=10"'| \
|
||||
@@ -26,7 +28,7 @@ cat config/config.json | \
|
||||
echo "Setting up fresh db"
|
||||
make ARGS="version --config $TMPDIR/config.json" run-cli
|
||||
|
||||
if [ "$SCHEMA_VERSION" == "5.0" ]; then
|
||||
if [ "$SCHEMA_VERSION" == "5.0.0" ]; then
|
||||
for i in "ChannelMembers MentionCountRoot" "ChannelMembers MsgCountRoot" "Channels TotalMsgCountRoot"; do
|
||||
a=( $i );
|
||||
echo "Ignoring known Postgres mismatch: ${a[0]}.${a[1]}"
|
||||
|
||||
Ссылка в новой задаче
Block a user