Add documentation for mattermots migtation to PostgeSQL.
This commit is contained in:
parent
543ee65fe0
commit
8f8741714d
@ -6,26 +6,26 @@
|
||||
#
|
||||
# https://docs.mattermost.com/deploy/postgres-migration.html
|
||||
|
||||
MATTERMOST_VERSION="9.11.6"
|
||||
MATTERMOST_VERSION="v9.11.6"
|
||||
|
||||
# Postgresql
|
||||
psql_db_host="10.0.3.42"
|
||||
psql_db_host="10.0.3.147"
|
||||
psql_db_port="5432"
|
||||
psql_db_name="mattermost"
|
||||
psql_db_user="mattermost"
|
||||
psql_db_password='aiqu7oghae1eZai3'
|
||||
|
||||
MYSQL_DSN="${mysql_db_user}:${mysql_db_password}@tcp(${mysql_db_host}:${mysql_db_port})/${mysql_db_name}"
|
||||
|
||||
# Mysql
|
||||
mysql_db_host="10.0.3.42"
|
||||
mysql_db_port="3306"
|
||||
mysql_db_name="mattermost2"
|
||||
mysql_db_user="mattermost2"
|
||||
mysql_db_password='aiqu7oghae1eZai3'
|
||||
psql_db_password='C5jzznfvn.-WV6J7-4rgT'
|
||||
|
||||
POSTGRES_DSN="postgres://${psql_db_user}:${psql_db_password}@${psql_db_host}:${psql_db_port}/${psql_db_name}"
|
||||
|
||||
# Mysql
|
||||
mysql_db_host="10.0.3.147"
|
||||
mysql_db_port="3306"
|
||||
mysql_db_name="mattermost"
|
||||
mysql_db_user="mattermost"
|
||||
mysql_db_password='C5jzznfvn%%WV6J7-4rgT'
|
||||
|
||||
MYSQL_DSN="${mysql_db_user}:${mysql_db_password}@tcp(${mysql_db_host}:${mysql_db_port})/${mysql_db_name}"
|
||||
|
||||
pgloader_bin='/usr/local/src/pgloader/pgloader/build/bin/pgloader'
|
||||
|
||||
|
||||
@ -147,6 +147,18 @@ systemctl stop postgresql
|
||||
systemctl start postgresql
|
||||
|
||||
|
||||
# ==============================
|
||||
#
|
||||
# Note: On mattermost Host in file my.cnf set:
|
||||
# ============================================
|
||||
#
|
||||
# [mysqld]
|
||||
# ...
|
||||
# default-authentication-plugin = mysql_native_password
|
||||
#
|
||||
# ==============================
|
||||
|
||||
|
||||
# ==============================
|
||||
# Automated PostgreSQL migration
|
||||
# ==============================
|
||||
@ -274,6 +286,20 @@ migration-assist pgloader --mysql $MYSQL_DSN --postgres $POSTGRES_DSN | tee mig
|
||||
# $$ ALTER USER mmuser SET SEARCH_PATH TO '"$user", public'; $$;
|
||||
|
||||
|
||||
# Step 3.1 - Add missing tables..
|
||||
# ===============================
|
||||
#
|
||||
#
|
||||
#
|
||||
# At mttermost host
|
||||
#
|
||||
# - Create sql file /root/bin/mattermost-migration.sql (includes miising tables/indexes/..)
|
||||
#
|
||||
# - run: cd /tmp; sudo -u postgres psql mattermost < /root/bin/mattermost-migration.sql
|
||||
#
|
||||
cd /tmp; sudo -u postgres psql mattermost < /root/bin/mattermost-migration.sql
|
||||
|
||||
|
||||
# Step 4 - Run pgloader
|
||||
# =====================
|
||||
#
|
||||
@ -336,43 +362,6 @@ sed -i '/mattermost.focalboard_teams/d' boards.load
|
||||
|
||||
${pgloader_bin} boards.load | tee boards_migration.log
|
||||
|
||||
|
||||
# playbooks.load
|
||||
#
|
||||
# Add missing entries into database:
|
||||
CREATE TABLE public.ir_category (
|
||||
id character varying(26) NOT NULL,
|
||||
name character varying(512) NOT NULL,
|
||||
teamid character varying(26) NOT NULL,
|
||||
userid character varying(26) NOT NULL,
|
||||
collapsed boolean DEFAULT false,
|
||||
createat bigint NOT NULL,
|
||||
updateat bigint DEFAULT 0 NOT NULL,
|
||||
deleteat bigint DEFAULT 0 NOT NULL
|
||||
);
|
||||
ALTER TABLE public.ir_category OWNER TO mattermost;
|
||||
|
||||
CREATE TABLE public.ir_category_item (
|
||||
type character varying(1) NOT NULL,
|
||||
categoryid character varying(26) NOT NULL,
|
||||
itemid character varying(26) NOT NULL
|
||||
);
|
||||
ALTER TABLE public.ir_category_item OWNER TO mattermost;
|
||||
|
||||
|
||||
ALTER TABLE ONLY public.ir_category_item
|
||||
ADD CONSTRAINT ir_category_item_pkey PRIMARY KEY (categoryid, itemid, type);
|
||||
|
||||
ALTER TABLE ONLY public.ir_category
|
||||
ADD CONSTRAINT ir_category_pkey PRIMARY KEY (id);
|
||||
|
||||
CREATE INDEX ir_category_item_categoryid ON public.ir_category_item USING btree (categoryid);
|
||||
CREATE INDEX ir_category_teamid_userid ON public.ir_category USING btree (teamid, userid);
|
||||
|
||||
ALTER TABLE ONLY public.ir_category_item
|
||||
ADD CONSTRAINT ir_category_item_categoryid_fkey FOREIGN KEY (categoryid) REFERENCES public.ir_category(id);
|
||||
#
|
||||
|
||||
${pgloader_bin} playbooks.load | tee playbooks_migration.log
|
||||
|
||||
${pgloader_bin} calls.load | tee calls.log
|
||||
|
265
mattermost-migration.sql
Normal file
265
mattermost-migration.sql
Normal file
@ -0,0 +1,265 @@
|
||||
|
||||
--
|
||||
-- Name: ir_category; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.ir_category (
|
||||
id character varying(26) NOT NULL,
|
||||
name character varying(512) NOT NULL,
|
||||
teamid character varying(26) NOT NULL,
|
||||
userid character varying(26) NOT NULL,
|
||||
collapsed boolean DEFAULT false,
|
||||
createat bigint NOT NULL,
|
||||
updateat bigint DEFAULT 0 NOT NULL,
|
||||
deleteat bigint DEFAULT 0 NOT NULL
|
||||
);
|
||||
ALTER TABLE public.ir_category OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_category_item; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.ir_category_item (
|
||||
type character varying(1) NOT NULL,
|
||||
categoryid character varying(26) NOT NULL,
|
||||
itemid character varying(26) NOT NULL
|
||||
);
|
||||
ALTER TABLE public.ir_category_item OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_channelaction; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.ir_channelaction (
|
||||
id character varying(26) NOT NULL,
|
||||
channelid character varying(26),
|
||||
enabled boolean DEFAULT false,
|
||||
deleteat bigint DEFAULT '0'::bigint NOT NULL,
|
||||
actiontype character varying(65536) NOT NULL,
|
||||
triggertype character varying(65536) NOT NULL,
|
||||
payload json NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.ir_channelaction OWNER TO mattermost;
|
||||
|
||||
--
|
||||
-- Name: ir_incident; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE public.ir_incident (
|
||||
id character varying(26) NOT NULL,
|
||||
name character varying(1024) NOT NULL,
|
||||
description character varying(4096) NOT NULL,
|
||||
isactive boolean NOT NULL,
|
||||
commanderuserid character varying(26) NOT NULL,
|
||||
teamid character varying(26) NOT NULL,
|
||||
channelid character varying(26) NOT NULL,
|
||||
createat bigint NOT NULL,
|
||||
endat bigint DEFAULT '0'::bigint NOT NULL,
|
||||
deleteat bigint DEFAULT '0'::bigint NOT NULL,
|
||||
activestage bigint NOT NULL,
|
||||
postid character varying(26) DEFAULT ''::character varying NOT NULL,
|
||||
playbookid character varying(26) DEFAULT ''::character varying NOT NULL,
|
||||
checklistsjson json NOT NULL,
|
||||
activestagetitle character varying(1024) DEFAULT ''::character varying,
|
||||
reminderpostid character varying(26),
|
||||
broadcastchannelid character varying(26) DEFAULT ''::character varying,
|
||||
previousreminder bigint DEFAULT '0'::bigint NOT NULL,
|
||||
remindermessagetemplate character varying(65536) DEFAULT ''::text,
|
||||
currentstatus character varying(1024) DEFAULT 'Active'::character varying NOT NULL,
|
||||
reporteruserid character varying(26) DEFAULT ''::character varying NOT NULL,
|
||||
concatenatedinviteduserids character varying(65536) DEFAULT ''::text,
|
||||
defaultcommanderid character varying(26) DEFAULT ''::character varying,
|
||||
announcementchannelid character varying(26) DEFAULT ''::character varying,
|
||||
concatenatedwebhookoncreationurls character varying(65536) DEFAULT ''::text,
|
||||
concatenatedinvitedgroupids character varying(65536) DEFAULT ''::text,
|
||||
retrospective character varying(65536) DEFAULT ''::text,
|
||||
messageonjoin character varying(65536) DEFAULT ''::text,
|
||||
retrospectivepublishedat bigint DEFAULT '0'::bigint NOT NULL,
|
||||
retrospectivereminderintervalseconds bigint DEFAULT '0'::bigint NOT NULL,
|
||||
retrospectivewascanceled boolean DEFAULT false,
|
||||
concatenatedwebhookonstatusupdateurls character varying(65536) DEFAULT ''::text,
|
||||
laststatusupdateat bigint DEFAULT '0'::bigint,
|
||||
exportchannelonfinishedenabled boolean DEFAULT false NOT NULL,
|
||||
categorizechannelenabled boolean DEFAULT false,
|
||||
categoryname character varying(65536) DEFAULT ''::text,
|
||||
concatenatedbroadcastchannelids character varying(65536) DEFAULT ''::text,
|
||||
channelidtorootid character varying(65536) DEFAULT ''::text,
|
||||
remindertimerdefaultseconds bigint DEFAULT '0'::bigint NOT NULL,
|
||||
statusupdateenabled boolean DEFAULT true,
|
||||
retrospectiveenabled boolean DEFAULT true
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.ir_incident OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_blocks; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.focalboard_blocks (
|
||||
id character varying(36) NOT NULL,
|
||||
insert_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
parent_id character varying(36),
|
||||
schema bigint,
|
||||
type text,
|
||||
title text,
|
||||
fields json,
|
||||
create_at bigint,
|
||||
update_at bigint,
|
||||
delete_at bigint,
|
||||
root_id character varying(36),
|
||||
modified_by character varying(36) NOT NULL,
|
||||
workspace_id character varying(36) NOT NULL,
|
||||
created_by character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE public.focalboard_blocks OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_blocks_history; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.focalboard_blocks_history (
|
||||
id character varying(36) NOT NULL,
|
||||
insert_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
parent_id character varying(36),
|
||||
schema bigint,
|
||||
type text,
|
||||
title text,
|
||||
fields json,
|
||||
create_at bigint,
|
||||
update_at bigint,
|
||||
delete_at bigint,
|
||||
root_id character varying(36),
|
||||
modified_by character varying(36),
|
||||
workspace_id character varying(36),
|
||||
created_by character varying(36)
|
||||
);
|
||||
|
||||
ALTER TABLE public.focalboard_blocks_history OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_sessions; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.focalboard_sessions (
|
||||
id character varying(100) NOT NULL,
|
||||
token character varying(100),
|
||||
user_id character varying(100),
|
||||
props json,
|
||||
create_at bigint,
|
||||
update_at bigint,
|
||||
auth_service character varying(20)
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.focalboard_sessions OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_users; Type: TABLE; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.focalboard_users (
|
||||
id character varying(100) NOT NULL,
|
||||
username character varying(100),
|
||||
email character varying(255),
|
||||
password character varying(100),
|
||||
mfa_secret character varying(100),
|
||||
auth_service character varying(20),
|
||||
auth_data character varying(255),
|
||||
props json,
|
||||
create_at bigint,
|
||||
update_at bigint,
|
||||
delete_at bigint
|
||||
);
|
||||
|
||||
ALTER TABLE public.focalboard_users OWNER TO mattermost;
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_blocks idx_25969_primary; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.focalboard_blocks
|
||||
ADD CONSTRAINT idx_25969_primary PRIMARY KEY (workspace_id, id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_blocks_history idx_25975_primary; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.focalboard_blocks_history
|
||||
ADD CONSTRAINT idx_25975_primary PRIMARY KEY (id, insert_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_sessions idx_25987_primary; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.focalboard_sessions
|
||||
ADD CONSTRAINT idx_25987_primary PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: focalboard_users idx_26003_primary; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.focalboard_users
|
||||
ADD CONSTRAINT idx_26003_primary PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_channelaction idx_26042_primary; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.ir_channelaction
|
||||
ADD CONSTRAINT idx_26042_primary PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_incident idx_26049_primary; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.ir_incident
|
||||
ADD CONSTRAINT idx_26049_primary PRIMARY KEY (id);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_category_item ir_category_item_pkey; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.ir_category_item
|
||||
ADD CONSTRAINT ir_category_item_pkey PRIMARY KEY (categoryid, itemid, type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_category ir_category_pkey; Type: CONSTRAINT; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.ir_category
|
||||
ADD CONSTRAINT ir_category_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_category_item_categoryid; Type: INDEX; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ir_category_item_categoryid ON public.ir_category_item USING btree (categoryid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ir_category_teamid_userid; Type: INDEX; Schema: public; Owner: mattermost
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ir_category_teamid_userid ON public.ir_category USING btree (teamid, userid);
|
||||
|
73
reinstall_postgresql.sh
Executable file
73
reinstall_postgresql.sh
Executable file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
MATTERMOST_VERSION="9.11.6"
|
||||
|
||||
# Postgresql
|
||||
psql_db_host="10.0.3.147"
|
||||
psql_db_port="5432"
|
||||
psql_db_name="mattermost"
|
||||
psql_db_user="mattermost"
|
||||
psql_db_password='C5jzznfvn.-WV6J7-4rgT'
|
||||
|
||||
POSTGRES_DSN="postgres://${psql_db_user}:${psql_db_password}@${psql_db_host}:${psql_db_port}/${psql_db_name}"
|
||||
|
||||
# Mysql
|
||||
mysql_db_host="10.0.3.147"
|
||||
mysql_db_port="3306"
|
||||
mysql_db_name="mattermost"
|
||||
mysql_db_user="mattermost"
|
||||
mysql_db_password='C5jzznfvn%%WV6J7-4rgT'
|
||||
|
||||
pgloader_bin='/usr/local/src/pgloader/pgloader/build/bin/pgloader'
|
||||
|
||||
MYSQL_DSN="${mysql_db_user}:${mysql_db_password}@tcp(${mysql_db_host}:${mysql_db_port})/${mysql_db_name}"
|
||||
|
||||
|
||||
echo ""
|
||||
|
||||
scho -e "\n\tapt purge -y postgresql postgresql-*"
|
||||
DEBIAN_FRONTEND=noninteractive apt purge -y postgresql postgresql-*
|
||||
|
||||
echo -e "\n\trm -rf /var/lib/postgresql"
|
||||
rm -rf /var/lib/postgresql
|
||||
|
||||
echo -e "\n\trm -rf /etc/postgresql"
|
||||
rm -rf /etc/postgresql
|
||||
|
||||
echo -e "\n\trm -rf /var/log/postgresql"
|
||||
rm -rf /var/log/postgresql
|
||||
|
||||
echo -e "\n\tDEBIAN_FRONTEND=noninteractive apt install -y --allow-unauthenticated postgresql"
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y --allow-unauthenticated postgresql
|
||||
|
||||
|
||||
echo -e "\n\t"cp -a /etc/postgresql/15/main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf.ORIG
|
||||
cp -a /etc/postgresql/15/main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf.ORIG
|
||||
echo -e "\n\t"cp /root/postgresql_15_main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf
|
||||
cp /root/postgresql_15_main/pg_hba.conf /etc/postgresql/15/main/pg_hba.conf
|
||||
|
||||
echo -e "\n\t"etc/postgresql/15/main/postgresql.conf /etc/postgresql/15/main/postgresql.conf.ORIG
|
||||
cp -a /etc/postgresql/15/main/postgresql.conf /etc/postgresql/15/main/postgresql.conf.ORIG
|
||||
echo -e "\n\t"p /root/postgresql_15_main/postgresql.conf /etc/postgresql/15/main/postgresql.conf
|
||||
cp /root/postgresql_15_main/postgresql.conf /etc/postgresql/15/main/postgresql.conf
|
||||
|
||||
echo ""
|
||||
|
||||
cd /tmp
|
||||
sudo -u postgres psql -c "CREATE DATABASE ${psql_db_name};"
|
||||
sudo -u postgres psql ${psql_db_name} -c "CREATE USER ${psql_db_user} WITH PASSWORD '${psql_db_password}';"
|
||||
sudo -u postgres psql ${psql_db_name} -c "GRANT ALL PRIVILEGES ON DATABASE ${psql_db_name} to ${psql_db_user};"
|
||||
sudo -u postgres psql ${psql_db_name} -c "ALTER DATABASE ${psql_db_name} OWNER TO ${psql_db_user};"
|
||||
sudo -u postgres psql ${psql_db_name} -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO ${psql_db_user};"
|
||||
sudo -u postgres psql ${psql_db_name} -c "ALTER SCHEMA public OWNER TO ${psql_db_user};"
|
||||
sudo -u postgres psql ${psql_db_name} -c "GRANT ALL ON SCHEMA public to ${psql_db_user};"
|
||||
|
||||
echo -e "\n\tsystemctl stop postgresql"
|
||||
systemctl stop postgresql
|
||||
|
||||
echo -e "\n\tsystemctl start postgresql"
|
||||
systemctl start postgresql
|
||||
|
||||
echo ""
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user