Homec4science

Add a `storage renamespace` for mangling SQL dumpfiles into a new namespace

Authored by epriestley <git@epriestley.com> on Mar 18 2015, 02:29.

Description

Add a storage renamespace for mangling SQL dumpfiles into a new namespace

Summary:
Ref T7149. When users give us dumpfiles for import, they will almost inevitably use the phabricator namespace. They need to be renamed to use an instance namespace.

We can do this either by:

  • importing the data first, then renaming; or
  • renaming first, then importing.

This implements the second one, basically storage renamespace --in dump.sql --from phabricator --to instancename > instance.sql.

Renaming first is a little hackier since we have to preg_match() a SQL dump file, but I think it's better overall:

  • With only one database, it lets you dump/import without downtime.
  • If you have development stuff in a development environment in the phabricator namespace, you don't have to move it aside to do an import.
  • No possibility that two people doing an import at the same time on the same box will collide with each other.
  • You can do the rename once and then repeat the import process with the renamed dump more easily.
  • No tricky stuff with modern Phabricator running against an old dump and the database names not matching up.

None of this is super important, but it just makes large dumps a bit easier to work with, and the dumpfile format is regular enough that this seems unlikely to ever really not work.

Test Plan: Renamespaced a dump, did a diff -u, saw all the relevant parts changed (and only those parts changed).

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7149

Differential Revision: https://secure.phabricator.com/D12105

Details

Committed
epriestley <git@epriestley.com>Mar 18 2015, 02:29
Pushed
aubortJan 31 2017, 17:16
Parents
rPH85de4419a5f1: Conpherence - add storage for view / edit / join policy
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH924b135d310b: Add a `storage renamespace` for mangling SQL dumpfiles into a new namespace (authored by epriestley <git@epriestley.com>).Mar 18 2015, 02:29