Schema creation fix

This commit is contained in:
Denis Zheleztsov 2015-04-10 12:01:28 +03:00
parent eb5fa3c9d4
commit de8a7421e4

View File

@ -45,7 +45,7 @@ sub mdo {
# Bad hack
if ( $name eq 'all' ) {
my $q
= 'select id, name, resource, username, comment from passwords';
= 'select id, name, `group`, resource, username, comment from passwords';
my $sth = $dbh->prepare($q);
my $rv = $sth->execute();
@ -54,19 +54,21 @@ sub mdo {
printf "%-11s %-11s %-11s %-11s %-11s\n",
colored( "ID", 'white' ),
colored( "NAME", 'magenta' ),
colored( "GROUP", 'bold magenta' ),
colored( "RESOURCE", 'blue' ),
colored( "USERNAME", 'green' ),
colored( "COMMENT", 'yellow' );
print "=================================\n";
while ( my ( $id, $name, $resource, $username, $comment )
print "=========================================\n";
while ( my ( $id, $name, $group, $resource, $username, $comment )
= $sth->fetchrow_array() )
{
if ( !defined($comment) ) {
$comment = '';
}
printf "%-11s %-11s %-11s %-11s %-11s\n",
printf "%-11s %-11s %-11s %-11s %-11s %-11s\n",
colored( $id, 'white' ),
colored( $name, 'magenta' ),
colored( $group, 'bold magenta' ),
colored( $resource, 'blue' ),
colored( $username, 'green' ),
colored( $comment, 'yellow' );
@ -137,8 +139,15 @@ sub create_base {
my $dbh = DBI->connect( "dbi:SQLite:dbname=$first_sqlite", "", "" );
print "Create database schema\n";
my $q_table
= "create table passwords(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(32), username VARCHAR(32),
resource TEXT, group VARCHAR(32), password TEXT, comment TEXT)";
= "CREATE TABLE passwords(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(32) NOT NULL,
username VARCHAR(32) NOT NULL,
resource TEXT NOT NULL,
password VARCHAR(32) NOT NULL,
comment TEXT NOT NULL,
'group' VARCHAR(32) NOT NULL
)";
$dbh->do($q_table);
print "Encrypt database...\n";