I've got this script
#!/bin/bash
name=test.sqlite
idx=1
while [ -e $name.$idx ]; do
idx=`expr $idx + 1`;
done
while [ $idx -gt 1 ]; do
nidx=`expr $idx - 1`; mv $name.$nidx $name.$idx; idx=$nidx;
done
[ ! -e $name ] || mv $name $name.1
sqlite3 test.sqlite < /path/to/db_schema.sh
and db_schema.sh
create table objects(id integer primary key autoincrement, name text, crc integer not null);
create index objects_idx on objects(crc);
create table symbols(id integer primary key autoincrement, name text, crc integer not null);
create index symbols_idx on symbols(crc);
create table provides(object_id integer not null, symbol_id integer not null);
create index provides_idx_sym on provides(symbol_id);
create index provides_idx_obj on provides(object_id);
create unique index provides_idx_key on provides(object_id, symbol_id);
create table depends(object_id integer not null, symbol_id integer not null);
create index depends_idx_sym on depends(symbol_id);
create index depends_idx_obj on depends(object_id);
create unique index depends_idx_key on depends(object_id,symbol_id);
This did work until today. What I tried so far
- hard-coding the path to
db_schema.sh - setting a variable to the file (
$DB_SCHEMA_VAR) - setting the path as variable but hardcoding the file (
$PATH_TO_FILE/db_schema.sh) - changing the folder the file is in and the three above
I also checked if the file is executable (it is), wrote a little line testing if the file is present
if [ -f db_schema.sh ] ; then ....
before the database gets created. The test shows db_schema.sh is there, but as soon as db_schema.sh gets called, it suddenly is no longer present.
And here the log output as asked for by Barefoot IO
+ DB_INIT (this is because i call it as a function and it is not a stand-alone script)
+ cd DB_wdsfasdfg
+ name=test.sqlite
+ idx=1
+ '[' -e test.sqlite.1 ']'
+ '[' 1 -gt 1 ']'
+ '[' '!' -e test.sqlite ']'
+ sqlite3 test.sqlite
./files/functions/init_db.sh: line 22: ./files/functions/db_schema.sh: No such file or directory
bash -x scriptfile 2> trace.log.