Only remove the right constraints on import

Authored by Lucas_Werkmeister_WMDE on Thu, Apr 20, 9:22 AM.


Only remove the right constraints on import

Once we start reading constraints from statements (which will also be
written to the database), the CSV file will no longer be the sole source
of constraints in the repository, so the import shouldn’t remove
constraints that didn’t come from the CSV file. Since we don’t track the
source of the constraints, and the script which extracts constraints
from templates does not produce stable UUIDs that can be compared
between database and CSV file, we distinguish between constraints to
delete and to keep via the format of their constraint IDs: the template
extractor produces regular UUIDs, whereas constraints from statements
will have a statement ID (entity ID, dollar sign, UUID).

The deletion of the old constraints is no longer batched; testing
indicates that even for the set of all Wikidata constraints (about 10000
lines in the CSV file), the deletion completes in less than 0.1 seconds,
so I think this is acceptable.

The test for the script is updated to check that old constraints with
proper UUIDs are deleted, but constraints with other kinds of IDs are
kept. This requires that the test CSV file gets proper UUIDs as
constraint IDs.

Change-Id: Iadcae75bc9384ea5bf0ac49f7fddf6a49f3bab0e