Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r209 r212 262 262 or return (undef, $DBI::errstr) if(!$dbh); 263 263 264 # Return here if we can't select. Note that this indicates a 265 # problem executing the select. 266 my $sth = $dbh->prepare("select group_id from groups limit 1"); 264 ##fixme: initialize the DB if we can't find the table (since, by definition, there's 265 # nothing there if we can't select from it...) 266 my $tblsth = $dbh->prepare("SELECT count(*) FROM pg_catalog.pg_class WHERE relkind='r' AND relname=?"); 267 my ($tblcount) = $dbh->selectrow_array($tblsth, undef, ('misc')); 268 return (undef,$DBI::errstr) if $dbh->err; 269 270 #if ($tblcount == 0) { 271 # # create tables one at a time, checking for each. 272 # return (undef, "check table misc missing"); 273 #} 274 275 276 # Return here if we can't select. 277 # This should retrieve the dbversion key. 278 my $sth = $dbh->prepare("SELECT key,value FROM misc WHERE misc_id=1"); 267 279 $sth->execute(); 268 280 return (undef,$DBI::errstr) if ($sth->err); 281 282 ##fixme: do stuff to the DB on version mismatch 283 # x.y series should upgrade on $DNSDB::VERSION > misc(key=>version) 284 # DB should be downward-compatible; column defaults should give sane (if possibly 285 # useless-and-needs-help) values in columns an older software stack doesn't know about. 269 286 270 287 # See if the select returned anything (or null data). This should -
trunk/dns.sql
r206 r212 5 5 -- CREATE DATABASE dnsdb OWNED BY dnsdb; 6 6 -- SET SESSION AUTHORIZATION 'dnsdb'; 7 8 -- need a handy place to put eg a DB version identifier - useful for auto-upgrading a DB 9 CREATE TABLE misc ( 10 misc_id serial NOT NULL, 11 key text DEFAULT '' NOT NULL, 12 value test DEFAULT '' NOT NULL 13 ); 14 15 COPY misc (misc_id, key, value) FROM stdin; 16 1 dbversion 1.0 17 \. 7 18 8 19 CREATE TABLE default_records ( … … 253 264 254 265 -- set starting sequence numbers, since we've inserted data before they're active 266 SELECT pg_catalog.setval('misc_misc_id_seq', 1, true); 255 267 SELECT pg_catalog.setval('default_records_record_id_seq', 8, true); 256 268 SELECT pg_catalog.setval('domains_domain_id_seq', 1, false);
Note:
See TracChangeset
for help on using the changeset viewer.