Hi Henrik,
> Hi, I'm in a bind, I'm using dbs+ with say 7, suddenly I find that I need
> to increase the number to something more to make more room for new stuff in
> the "base" ER so to speak.
>
> Simply changing the number doesn't work, it gives me "Bad DB file" which is
> quite understandable.
>
> How can I resolve this without losing any data?
This is a tough one. A lot of database objects must be moved to
different files.
I would, in general, not recommend that, and rather try to extend the DB
"horizontally", i.e. by putting new classes and indexes into existing
'dbs' entries (files).
But if absolutely necessary, it can be done. I see two ways:
1. Completely rebuild the DB. For that, export all entities:
(load "@lib/too.l") # for 'dump'
(out "myData.l"
(prinl "# " (stamp))
(prinl)
(prinl "# Roles")
(dump (db nm +Role @@))
(println '(commit))
(prinl)
(prinl "# User")
(dump (db nm +User @@))
(println '(commit))
(prinl)
(prinl "# SomeClass")
(dump (db key +Cls1 @@))
(println '(commit))
(prinl)
(prinl "# SomeOtherClass")
(dump (db key +Cls2 @@))
(println '(commit))
(prinl)
... )
You must find proper Pilog expressions to select all entities. This
depends on the class(es) and the indexes involved. To put it simply,
you must find an index for each class that is complete, i.e. which
indexes all objects of that class.
Take care not to forget anything :)
The resulting file can be imported into the newly structured, but
still empty, DB with
: (load "myData.l")
This works rather well, but requires thorough testing and checking of
the new DB.
2. There is a possibility to re-organize an existing DB. This can be
done with 'dbfMigrate' in "@lib/too.l". At least theoretically ;-)
I haven't yet used it in that way. But I used it rather often to port
databases from pil32 to pil64 format, which involves similar
problems, and it always worked reliably.
So you might give it a try (after backing up your DB, of course). When
you changed '*Dbs' (i.e. the 'dbs' and 'dbs+' calls), you open the DB
as before
: (pool "db/xxx/" *Dbs)
and then cross your fingers and call
: (dbfMigrate "db/xxx/" *Dbs)
Also, you should perform the usual DB check
: (dbCheck)
I hope I didn't forget anything ;-)
♪♫ Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe