PApp
view release on metacpan or search on metacpan
papp-install view on Meta::CPAN
SQL
if ($installed_version < 0.142) {
$DBH->do("drop table state") if $mode_update;
sql_exec <<SQL;
create table /*! if not exists */ state (
id int(10) unsigned not null,
ctime timestamp,
previd int(10) unsigned default '0' not null,
alternative mediumint(8) unsigned default '0' not null,
userid int(10) unsigned default '0' not null,
sessid int(10) unsigned default '0' not null,
state mediumblob default '' not null,
primary key (id),
key (alternative, previd)
) delay_key_write=1 $create_options
SQL
}
if ($installed_version < 0.143) {
if ($mode_update) {
$DBH->do("drop table eventcount");
$DBH->do("alter table msgid change id id mediumblob not null, change context context blob not null");
$DBH->do("alter table msgstr change msg msg mediumblob not null");
}
sql_exec <<SQL;
create table /*! if not exists */ event_count (
count int(10) unsigned not null
) $create_options
SQL
}
unless (sql_fetch "select count(*) from event_count") {
sql_exec "insert into event_count values (0)";
sql_exec "delete from event";
}
sql_exec <<SQL;
create table /*! if not exists */ state_seq (
seq int(10) unsigned not null
) $create_options
SQL
unless (sql_fetch "select count(*) from state_seq") {
sql_exec "insert into state_seq values (1)";
sql_exec "delete from state";
}
sql_exec <<SQL;
create table /*! if not exists */ session (
sid int(10) unsigned not null default '0',
name varchar(255) binary not null default '',
value mediumblob not null,
unique key id (sid,name(200))
) $create_options
SQL
sql_exec <<SQL;
create table /*! if not exists */ prefs (
uid int(10) unsigned not null default '0',
path varchar(255) binary not null default '',
name varchar(255) binary not null default '',
value mediumblob not null,
unique key id (path(140),name(100),uid)
) $create_options
SQL
if ($mode_update && $installed_version < 0.142) {
eval {
my $st = sql_exec \my($userid, $prefs, $user, $pass, $comment),
"select id, prefs, user, pass, comment from user";
print "Converting user preferences data to new format";
while ($st->fetch) {
print ".";
if ($user ne "") {
sql_exec "replace into prefs (uid, path, name, value) values (?,'',?,?)",
$userid, "papp_username", sfreeze_cr $user;
}
if ($pass ne "") {
sql_exec "replace into prefs (uid, path, name, value) values (?,'',?,?)",
$userid, "papp_password", sfreeze_cr $pass;
}
if ($comment ne "") {
sql_exec "replace into prefs (uid, path, name, value) values (?,'',?,?)",
$userid, "papp_comment", sfreeze_cr $comment;
}
if ($prefs ne "") {
$prefs = PApp::Storable::thaw decompress $prefs;
while (my ($path, $keys) = each %$prefs) {
next unless %$keys;
sql_exec $DBH, "replace into prefs (uid, path, name, value) values (?,?,?,?)",
$userid, $path, "papp_prefs",
compress PApp::Storable::nfreeze($keys);
}
}
}
print " done.\n";
};
}
if ($mode_update && $installed_version < 0.21) {
sql_exec "drop table /*! if exists */ obj_isa";
}
if ($mode_update && $installed_version < 0.22) {
sql_exec "drop table /*! if exists */ obj_attr";
}
sql_exec <<SQL;
create table /*! if not exists */ user_seq (
seq int(10) unsigned not null
) $create_options
SQL
unless (sql_fetch "select count(*) from user_seq") {
sql_exec "insert into user_seq values (?)", 0+sql_fetch "select max(uid) + 1 from prefs";
}
$DBH->do("drop table user") if $mode_update && $installed_version < 0.142;
$DBH->do("alter table grp add comment text not null") if $mode_update && $installed_version < 0.124;
$DBH->do("alter table grp add unique key (name)") if $mode_update && $installed_version < 0.124;
$DBH->do("alter table grp change name name varchar(160) not null") if $mode_update && $installed_version < 0.14;
sql_exec <<SQL;
create table /*! if not exists */ grp (
id int(10) unsigned not null auto_increment,
name varchar(100) not null,
comment text not null,
primary key (id),
unique (name)
) $create_options
SQL
sql_exec <<SQL;
create table /*! if not exists */ usergrp (
userid int(10) unsigned default '0' not null,
grpid int(8) unsigned default '0' not null,
primary key (userid,grpid)
) $create_options
SQL
sql_exec <<SQL;
create table /*! if not exists */ app (
id smallint(6) unsigned not null auto_increment,
name varchar(255) binary default '' not null,
appset smallint(5) unsigned default '0' not null,
path varchar(255) binary default '' not null,
mountconfig mediumtext default '' not null,
config mediumtext default '' not null,
primary key (id),
unique (name)
) $create_options
SQL
sql_exec <<SQL;
create table /*! if not exists */ appset (
id smallint(5) unsigned not null auto_increment,
name varchar(255) default '' not null,
primary key (id),
unique (name)
) $create_options
SQL
sql_exec <<SQL;
create table /*! if not exists */ locks (
id varchar(255) binary default '' not null,
breaktime int(10) unsigned default '0' not null,
data varchar(255) binary default '' not null,
primary key (id)
) $create_options
SQL
$DBH->do("drop table error") if $installed_version && $installed_version < 0.13;
sql_exec <<SQL;
create table /*! if not exists */ error (
papp-install view on Meta::CPAN
sql_exec <<SQL;
CREATE TABLE obj_path (
id tinyint(8) unsigned NOT NULL,
path varchar(255) NOT NULL,
PRIMARY KEY (id)
) $create_options
SQL
sql_exec "update env set name = 'PAPP_SYSID' where name = 'SYSID'";
}
my $installed_sysid = sql_fetch "select value from env where name = 'PAPP_SYSID'";
die "installation sysid and configured sysid don't match"
if $installed_sysid > 0 && $CFG{SYSID} > 0 && $installed_sysid != $CFG{SYSID};
if ($CFG{SYSID} > 0 && $installed_sysid == 0) {
sql_exec "delete from env where name = 'PAPP_SYSID'";
sql_exec "insert into env (name, value) values ('PAPP_SYSID', ?)", $CFG{SYSID};
$installed_sysid = $CFG{SYSID};
}
if ($installed_sysid) {
my $measured_sysid = sql_fetch "select seq >> 32 from obj_gidseq";
if ($measured_sysid == 0) {
sql_exec "delete from obj_gidseq";
sql_exec "insert into obj_gidseq values ((? << 32) + 1)", $installed_sysid;
}
die "PAPP_SYSID and actual obj_gidseq do NOT match"
if $measured_sysid > 0 && $measured_sysid != $installed_sysid;
}
{
# check the sysid
my ($sysid, $oid) = sql_fetch "select seq >> 32, seq & 0xffffffff from obj_gidseq"
or die "no sysid installed, a sysid is now required, please make reconfig";
my $maxid = sql_fetch "select max(gid) & 0xffffffff from obj where gid >= (? << 32) and gid < (? << 32)",
$sysid, $sysid+1;
$maxid < $oid
or die "installation check found objects > oidseq, either your sysid is broken or your database is corrupt";
}
print <<EOF;
Now populating tables (that hopefully do exist now). Any errors in this
section are supposedly fatal(!!).
EOF
if ($mode_init) {
$DBH->do("insert into appset values (1, 'default')")
or warn "unable to create 'default' appset: $DBI::errstr\n";
print "creating admin user and admin group... ";
eval {
my $pass = crypt "public", "xx";
$DBH->do("insert into prefs values (1, '', 'papp_username', 'admin')")
and $DBH->do("insert into prefs values (1, '', 'papp_password', '$pass')")
and $DBH->do("insert into prefs values (1, '', 'papp_comment', 'Main Administrator')")
and $DBH->do("insert into grp values (1, 'admin' , 'hyperuser access rights')")
and $DBH->do("insert into grp values (2, 'poedit' , 'general translator access')")
and $DBH->do("insert into grp values (3, 'poedit_*' , 'translator access for all apps')")
and $DBH->do("insert into grp values (4, 'poedit_papp', 'translator access for papp itself')")
and $DBH->do("insert into usergrp values (1, 1)")
and $DBH->do("insert into usergrp values (1, 2)")
and $DBH->do("insert into usergrp values (1, 3)")
or die;
print <<EOF;
ok
********* the admin user is named 'admin' *********
********* and has the initial password 'public' *********
********* please change this ASAP using *********
********* papp-admin -u admin --password <password> *********
EOF
};
if ($@) {
print "failed (or already exists)\n";
}
}
print "\nimporting i18n tables\n";
for my $domain (qw(papp bench dbedit demo iso639 iso3166)) {
PApp::Admin::import_po 0, "i18n/$domain.po", 1;
print "exporting $domain to $CFG{I18NDIR}/$domain\n";
PApp::I18n::export_dpo $domain, "$CFG{I18NDIR}/$domain", $CFG{PAPP_UID}, $CFG{PAPP_GID};
}
$DBH->do("delete from env where name='PAPP_VERSION'");
$DBH->do("insert into env (name, value) values ('PAPP_VERSION', '$PApp::Config::VERSION')");
}
( run in 0.711 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )