Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If DB up-to-date, exit status is 1 #24

Closed
mbucc opened this issue Apr 3, 2017 · 1 comment
Closed

If DB up-to-date, exit status is 1 #24

mbucc opened this issue Apr 3, 2017 · 1 comment

Comments

@mbucc
Copy link
Owner

mbucc commented Apr 3, 2017

bbox:/service/elmarelli-api$ shmig -c db/shmig.conf up
shmig: creating migrations table: shmig_version
shmig: applying  'venue_events'	(1485620534)... done
shmig: applying  'fan'	(1488727517)... done
bbox:/service/elmarelli-api$ echo $?
0
bbox:/service/elmarelli-api$ shmig -c db/shmig.conf up
bbox:/service/elmarelli-api$ echo $?
1
@mbucc
Copy link
Owner Author

mbucc commented Apr 3, 2017

Output from set -x:

+ ACTION=up
+ shift
++ type -t sqlite3_check
+ [[ function = \f\u\n\c\t\i\o\n ]]
+ sqlite3_check
+ __generic_checker /usr/bin/sqlite3 'select name from sqlite_master where type = '\''table'\'';' 'create table `shmig_version`(version int not null primary key, migrated_at timestamp not null default (datetime(current_timestamp)));'
+ local exe=/usr/bin/sqlite3
+ local 'show=select name from sqlite_master where type = '\''table'\'';'
+ local 'create=create table `shmig_version`(version int not null primary key, migrated_at timestamp not null default (datetime(current_timestamp)));'
+ [[ -x /usr/bin/sqlite3 ]]
+ grep -F -qx shmig_version
+ sqlite3_cli 'select name from sqlite_master where type = '\''table'\'';'
+ local 'args=-bail -batch  elmarelli-api.db'
+ [[ 1 -ne 0 ]]
+ /usr/bin/sqlite3 -bail -batch elmarelli-api.db
+ status=("${PIPESTATUS[@]}")
+ local status
+ [[ 141 -ne 0 ]]
+ return 1
+ exit 1

But this worked fine:

$ bash
$ sqlite3 -bail -batch  elmarelli-api.db <<< 'select name from sqlite_master where type = '\''table'\'';'
shmig_version
venue
venue_event
fan
fan_event
$

Somehow, this code:

  local status=("${PIPESTATUS[@]}")

  [[ ${status[0]} -ne 0 ]] && return 1

(ref:

shmig/shmig

Lines 169 to 171 in e4c58f9

local status=("${PIPESTATUS[@]}")
[[ ${status[0]} -ne 0 ]] && return 1
)

produces this output

+ local status
+ [[ 141 -ne 0 ]]
+ return 1

@mbucc mbucc closed this as completed in 0ee05a7 Apr 3, 2017
@mbucc mbucc mentioned this issue Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant