aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/Migration/SqliteInventory.pl
blob: c59cbcee5af1bd5e4937940f6b12075fb5466dfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl

# -- CREATE TABLE inventoryitems(UUID varchar(255) primary key,
# -- assetID varchar(255),
# -- assetType integer,
# -- invType integer,
# -- parentFolderID varchar(255),
# -- avatarID varchar(255),
# -- creatorsID varchar(255),
# -- inventoryName varchar(255),
# -- inventoryDescription varchar(255),
# -- inventoryNextPermissions integer,
# -- inventoryCurrentPermissions integer,
# -- inventoryBasePermissions integer,
# -- inventoryEveryOnePermissions integer);

# -- CREATE TABLE inventoryfolders(UUID varchar(255) primary key,
# -- name varchar(255),
# -- agentID varchar(255),
# -- parentID varchar(255),
# -- type integer,
# -- version integer);

my $items = "INSERT INTO InventoryItems(ID, AssetID, AssetType, InvType, Folder, Owner, Creator, Name, Description, NextPermissions, CurrentPermissions, BasePermissions, EveryOnePermissions) ";
my $folders = "INSERT INTO InventoryFolders(ID, Name, Owner, ParentID, Type, Version) ";

open(SQLITE, "sqlite3 inventoryStore.db .dump |") or die "can't open the database for migration";
open(WRITE,"| sqlite3 Inventory.db");

while(my $line = <SQLITE>) {
    $line =~ s/([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})/$1-$2-$3-$4-$5/g;
    if($line =~ s/(INSERT INTO "inventoryitems")/$items/) {
        print $line;
        print WRITE $line;
    }
    if($line =~ s/(INSERT INTO "inventoryfolders")/$folders/) {
        print $line;
        print WRITE $line;
    }    
}

close(WRITE);
close(SQLITE);