+sub action_schema {
+ my %args = @_;
+ my $dbh = get_admin_dbh();
+ my ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'schema' );
+ return ($status, $msg) unless $status;
+
+ my $individual_id = Data::GUID->new->as_string();
+ my %upgrade_data = (
+ action => 'schema',
+ filename => Cwd::abs_path($args{'datafile'} || $args{'datadir'} || ''),
+ stage => 'before',
+ full_id => $full_id,
+ individual_id => $individual_id,
+ );
+ $upgrade_data{'ext_version'} = $ext_version if $ext_version;
+ RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
+
+ print "Now populating database schema.\n";
+ my @ret = RT::Handle->InsertSchema( $dbh, $args{'datafile'} || $args{'datadir'} );
+
+ %upgrade_data = (
+ stage => 'after',
+ individual_id => $individual_id,
+ return_value => [ @ret ],
+ );
+ RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
+
+ return @ret;
+}
+
+sub action_acl {
+ my %args = @_;
+ my $dbh = get_admin_dbh();
+ my ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'acl' );
+ return ($status, $msg) unless $status;
+
+ my $individual_id = Data::GUID->new->as_string();
+ my %upgrade_data = (
+ action => 'acl',
+ filename => Cwd::abs_path($args{'datafile'} || $args{'datadir'} || ''),
+ stage => 'before',
+ full_id => $full_id,
+ individual_id => $individual_id,
+ );
+ $upgrade_data{'ext_version'} = $ext_version if $ext_version;
+ RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
+
+ print "Now inserting database ACLs.\n";
+ my @ret = RT::Handle->InsertACL( $dbh, $args{'datafile'} || $args{'datadir'} );
+
+ %upgrade_data = (
+ stage => 'after',
+ individual_id => $individual_id,
+ return_value => [ @ret ],
+ );
+ RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
+
+ return @ret;
+}
+
+sub action_indexes {
+ my %args = @_;
+ RT->ConnectToDatabase;
+ my $individual_id = Data::GUID->new->as_string();
+ my %upgrade_data = (
+ action => 'indexes',
+ filename => Cwd::abs_path($args{'datafile'} || $args{'datadir'} || ''),
+ stage => 'before',
+ full_id => $full_id,
+ individual_id => $individual_id,
+ );
+ $upgrade_data{'ext_version'} = $ext_version if $ext_version;
+ RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
+
+ my $dbh = get_admin_dbh();
+ $RT::Handle = RT::Handle->new;
+ $RT::Handle->dbh( $dbh );
+ RT::InitLogging();
+
+ print "Now inserting database indexes.\n";
+ my @ret = RT::Handle->InsertIndexes( $dbh, $args{'datafile'} || $args{'datadir'} );
+
+ $RT::Handle = RT::Handle->new;
+ $RT::Handle->dbh( undef );
+ RT->ConnectToDatabase;
+ %upgrade_data = (
+ stage => 'after',
+ individual_id => $individual_id,
+ return_value => [ @ret ],
+ );
+ RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
+
+ return @ret;
+}
+
+sub action_coredata {
+ my %args = @_;
+ $RT::Handle = RT::Handle->new;
+ $RT::Handle->dbh( undef );
+ RT::ConnectToDatabase();
+ my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'coredata' );
+ return ($status, $msg) unless $status;
+
+ print "Now inserting RT core system objects.\n";
+ return $RT::Handle->InsertInitialData;
+}
+
+sub action_insert {
+ state $RAN_INIT;
+ my %args = @_;
+ unless ($RAN_INIT) {
+ $RT::Handle = RT::Handle->new;
+ RT::Init();
+ $RAN_INIT++;