AmberDB
view release on metacpan or search on metacpan
lib/AmberDB.pm view on Meta::CPAN
unless ( $self->config('no_backup') || $table_info->{no_backup} ) {
$self->recs_back( "add", $tableid, @batch );
}
}
return \%statu;
}
# Replace the DB record with new data.
# ------------------------------------------------
sub update_id {
my ( $self, $tableid, $rid, @record ) = @_;
# Perform the checks.
$tableid or return;
if ( ref($rid) eq 'HASH' && !@record ) {
if ( $self->schema_matches_hash( $tableid, $rid ) ) {
my $h = { %$rid };
$rid = $h->{id} // $h->{ID};
lib/AmberDB.pm view on Meta::CPAN
# Authorization
$self->auth_write( $tableid, $table_path, "edit", $rid ) unless ( $is_async_write || $use_ramdisk == 3 );
$self->_invalidate_child_ramdisk_tables($tableid);
return 1;
}
# List record modify.
# Note: Bulk operations (insert_list, modify_list, delete_list) do NOT use transactions (_txn_log).
# ------------------------------------------------
sub update_list {
my ( $self, $tableid, @records ) = @_;
local $self->{_no_txn} = 1;
$tableid or return {};
scalar @records or return {};
# Deflate ONLY if table has a schema and records match schema
my $should_deflate = 0;
lib/AmberDB.pm view on Meta::CPAN
sub modify_list { shift->update_list(@_) }
# Updates a field value in an existing record.
# Supports updating fixed schema blocks:
# $adb->update_field($table, $rid, "price", 1750)
# $adb->update_field($table, $rid, block => "price", 1750)
# Supports updating repeating child items by 'id' or 'pos':
# $adb->update_field($table, $rid, id => 202, $new_item)
# $adb->update_field($table, $rid, pos => 0, $new_item)
# ------------------------------------------------
sub update_field {
my $self = shift;
my $tableid = shift;
my $rid = shift;
$tableid or return;
$rid = $self->id_check( $tableid, $rid );
$rid or return;
my ( $target_spec, $new_val );
if ( @_ == 3 && !ref($_[0]) ) {
lib/AmberDB/Tools/Update.pm view on Meta::CPAN
}
# ---------------------------------------------------------------------
# update_table($tableid, %options)
# Scans an entire table record-by-record, detects any legacy formats (2003-2026),
# creates a timestamped backup with detected dominant version, and rewrites the table
# directly in ABR v1 format preserving original IDs.
# Rebuilds indexes using ($self->can('set_index') ? $self : do { require AmberDB::Tools::Index; AmberDB::Tools::Index->new($adb); })->set_index($tableid).
# Preserves companion data files ('del', 'aut').
# ---------------------------------------------------------------------
sub update_table {
my ( $self, $tableid, %opts ) = @_;
my $adb = $self->{_adb} or return;
$tableid or return;
my $table_path = $adb->table_path($tableid);
my $ext = $adb->{db_ext} || "db";
my $file_path = "$table_path.$ext";
# Use exist_table to verify primary table existence
return { status => 'not_found', table => $tableid }
lib/AmberDB/Tools/Update.pm view on Meta::CPAN
unq_backup => $unq_backup,
has_cnt => $has_cnt ? 1 : undef,
cnt_backup => $cnt_backup,
};
}
# ---------------------------------------------------------------------
# update_all(%options)
# Iterates through all discovered tables and runs update_table on each.
# ---------------------------------------------------------------------
sub update_all {
my ( $self, %opts ) = @_;
my $adb = $self->{_adb} or return;
my @tables = ($self->can('all_tables') ? $self->all_tables() : do { require AmberDB::Tools::Maintain; AmberDB::Tools::Maintain->new($self->{_adb})->all_tables(); });
my @results;
foreach my $table (@tables) {
my $res = $self->update_table( $table, %opts );
push @results, $res if $res;
}
lib/AmberDB/Tools/Update.pm view on Meta::CPAN
# Creates a compressed, portable .amberdb archive containing table schemas,
# native data files (.db, .del, .aut, .cnt), and integrity manifest.
# my $archive = $tools->dump( [file => 'backup.amberdb'], [tables => ['t1', 't2']] );
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------
# update_version(%opts)
# Checks MetaCPAN API for latest AmberDB release and optionally installs via cpanm.
# ---------------------------------------------------------------------
sub update_version {
my ( $self, %opts ) = @_;
my $opt_check = $opts{check} // 0;
my $opt_cpanm = $opts{cpanm} // '';
print "=================================================================\n";
print " AmberDB Core Engine Update Utility \n";
print "=================================================================\n";
print "Current Engine Version : v$AmberDB::VERSION\n";
my $api_url = "https://fastapi.metacpan.org/v1/release/AmberDB";
lib/AmberDB/Tools/Update.pm view on Meta::CPAN
return { status => 'manual_required', latest => $latest_version };
}
}
# ---------------------------------------------------------------------
# update_storage(%opts)
# Migrates storage directory layout (scheme->schema, tables->table),
# upgrades table record formats to native ABR v5, rebuilds secondary indexes,
# and stamps config/storage_version.json.
# ---------------------------------------------------------------------
sub update_storage {
my ( $self, %opts ) = @_;
my $adb = $self->{_adb};
my $target_dir = $opts{target_dir}
|| ( $adb ? $adb->path('dbase_dir') : undef )
|| $opts{dbase_dir}
|| $opts{dbase};
if ( !defined $target_dir || $target_dir eq '' ) {
my $cwd = eval { Cwd::abs_path(Cwd::getcwd()) } // '.';
( run in 1.625 second using v1.01-cache-2.11-cpan-145b269f2f3 )