Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Rename schema to public after using pgloader

Oliver Günther9126cf777fc5
diff --git a/docker/mysql-to-postgres/bin/migrate-mysql-to-postgres b/docker/mysql-to-postgres/bin/migrate-mysql-to-postgres
index 68b400e1a07..917c1b60dd3 100755
--- a/docker/mysql-to-postgres/bin/migrate-mysql-to-postgres
+++ b/docker/mysql-to-postgres/bin/migrate-mysql-to-postgres
@@ -125,6 +125,20 @@ if pgloader_status != 0
exit 1
end
+mysql_db_name = mysql_url.path.sub("/", "")
+if mysql_db_name != 'public'
+ puts "Renaming to public schema"
+ rename_schema_cmd = "PGPASSWORD=#{db_password} psql -o /dev/stdout -U #{db_user} -h #{db_host} -p #{db_port} -d #{db_name} -c \"DROP schema public; ALTER schema #{mysql_db_name} RENAME to public;\""
+ check_output, check_status = run rename_schema_cmd, silent: false
+
+ if check_status != 0
+ puts check_output
+ puts "Failed to rename schema #{mysql_db_name} to public. See above."
+
+ exit 1
+ end
+end
+
check_fulltext_cmd = "PGPASSWORD=#{db_password} psql -o /dev/stdout -U #{db_user} -h #{db_host} -p #{db_port} -d #{db_name} -c \"select 'true' from schema_migrations where version = '20180122135443'\""
check_output, check_status = run check_fulltext_cmd, silent: true