[Rt-commit] rt branch, 4.4/serialize-json-initialdata, updated. rt-4.4.1-424-gb28da74
Shawn Moore
shawn at bestpractical.com
Thu Mar 23 14:04:07 EDT 2017
The branch, 4.4/serialize-json-initialdata has been updated
via b28da74ced454cc59311a500bb684b6d7a09fb15 (commit)
from 4eb950c93f76df9d0d6ee701551b43a1f1040fb9 (commit)
Summary of changes:
lib/RT/Migrate/Serializer.pm | 2 ++
lib/RT/Migrate/Serializer/JSON.pm | 11 +++++++----
sbin/rt-serializer.in | 8 ++++++++
3 files changed, 17 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit b28da74ced454cc59311a500bb684b6d7a09fb15
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 23 17:58:14 2017 +0000
Add --sync option which keeps record ids
diff --git a/lib/RT/Migrate/Serializer.pm b/lib/RT/Migrate/Serializer.pm
index b188aa7..4baeda0 100644
--- a/lib/RT/Migrate/Serializer.pm
+++ b/lib/RT/Migrate/Serializer.pm
@@ -75,6 +75,7 @@ sub Init {
Clone => 0,
Incremental => 0,
+ Sync => 0,
Verbose => 1,
@_,
@@ -95,6 +96,7 @@ sub Init {
FollowACL
Clone
Incremental
+ Sync
/;
$self->{Clone} = 1 if $self->{Incremental};
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 31909b4..5eb0a30 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -419,7 +419,7 @@ sub CanonicalizeObjectCustomFieldValues {
next unless $cf && $cf->{Name}; # disabled CF on live object
$record->{CustomField} = $cf->{Name};
- delete @$record{qw/id/};
+ delete $record->{id} unless $self->{Sync};
push @{ $object->{CustomFields} }, $record;
}
@@ -459,7 +459,8 @@ sub CanonicalizeObjects {
my %object = %$_;
return if $object{Disabled} && !$self->{FollowDisabled};
- delete @object{qw/id CustomField/};
+ delete $object{CustomField};
+ delete $object{id} unless $self->{Sync};
delete $object{Category} if !length($object{Category});
delete $object{Description} if !length($object{Description});
return \%object;
@@ -503,7 +504,8 @@ sub CanonicalizeObjects {
},
canonicalize_object => sub {
my %object = %$_;
- delete @object{qw/id Scrip/};
+ delete $object{Scrip};
+ delete $object{id} unless $self->{Sync};
if (ref($_->{ObjectId})) {
my $serialized = $self->_GetSerializedByRef($_->{ObjectId});
@@ -570,6 +572,7 @@ sub WriteFile {
$self->CanonicalizeArticles;
my $all_records = $self->{Records};
+ my $sync = $self->{Sync};
delete $all_records->{'RT::Attribute'};
@@ -594,7 +597,7 @@ sub WriteFile {
$record->{$key} = $self->CanonicalizeReference($record->{$key}, $record, $key);
}
}
- delete $record->{id};
+ delete $record->{id} unless $sync;
delete $record->{Disabled} if !$record->{Disabled};
push @{ $output{$outtype} }, $record;
diff --git a/sbin/rt-serializer.in b/sbin/rt-serializer.in
index 2448c9d..5fee4d0 100644
--- a/sbin/rt-serializer.in
+++ b/sbin/rt-serializer.in
@@ -111,6 +111,7 @@ GetOptions(
"clone",
"incremental",
+ "sync",
"gc=i",
"page=i",
@@ -136,6 +137,7 @@ $args{FollowAssets} = $OPT{assets} if defined $OPT{assets};
$args{Clone} = $OPT{clone} if $OPT{clone};
$args{Incremental} = $OPT{incremental} if $OPT{incremental};
+$args{Sync} = $OPT{sync} if $OPT{sync};
$args{GC} = defined $OPT{gc} ? $OPT{gc} : 5000;
$args{Page} = defined $OPT{page} ? $OPT{page} : 100;
@@ -372,6 +374,12 @@ your IncrementalRecords database table. This assumes that you have created
that table and run RT using the Record_Local.pm shim as documented in
C<docs/incremental-export/>.
+=item B<--sync>
+
+When exporting an initialdata, record ids are ordinarily excluded. Pass
+C<--sync> to include record ids if you intend to use this for sync
+rather than creating a generic initialdata.
+
=item B<--gc> I<n>
Adjust how often the garbage collection sweep is done; lower numbers are
-----------------------------------------------------------------------
More information about the rt-commit
mailing list