structure.sql file is modified on running migrations, things are added - ruby-on-rails

After running 'rails db:migrate' my structure file is modified in a way that is different then my coworkers. for example:
CREATE SEQUENCE public.foo_bar_seq
+ AS integer --<< this is added.
START WITH 1
INCREMENT BY 1
NO MINVALUE
- WHERE sometime > ((('now'::text)::date - '3 mons'::interval) - '8 days'::interval))
+ WHERE sometime > ((CURRENT_DATE - '3 mons'::interval) - '8 days'::interval)) -- becomes this
I can't figure it out and is highly annoying as I have to commit by line changes to my structure file whenever I add a migration. We are all using the same version of psql 11.2.

sometimes different versions of postgresql running on your local machine changes the structure as well.

Related

Experiment does not run due to Error Messages

I have started programming an Arithmetic Strategy Use task in PsychoPy. The idea is to have a total of 80 arithmetic problems, which would essentially end up being 4 conditions; single addition (20 problems), single subtraction (20 problems), double addition (20 problems), double subtraction (20 problems).
What I have done so far:
I created 4 excel sheets; one per condition with 20 arithmetic problems
I inserted a routine called Trial and inserted 4 loops with Single Subtraction, Single Addition, Double Subtraction and Double addition.
I included a strategy report question after each trial
I tried to run the experiment, however, several error messages keep popping up and I am not sure how to troubleshoot them! Please find the error messages below:
*Traceback (most recent call last):
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 1419, in onPavloviaRun
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 1413, in onPavloviaSync
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/pavlovia_ui/project.py”, line 844, in syncProject
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/pavlovia_ui/functions.py”, line 148, in showCommitDialog
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/projects/pavlovia.py”, line 1167, in commit
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/git/cmd.py”, line 542, in
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/git/cmd.py”, line 1005, in _call_process
File “/Users/nina/Desktop/PsychoPy.app/Contents/Resources/lib/python3.8/git/cmd.py”, line 822, in execute
git.exc.GitCommandError: Cmd(‘/Users/nina/Desktop/PsychoPy.app/Contents/Resources/git-core/git’) failed due to: exit code(128)
cmdline: /Users/nina/Desktop/PsychoPy.app/Contents/Resources/git-core/git commit -m _
stderr: ‘fatal: Unable to create ‘/Users/ninajost/Desktop/.git/index.lock’: File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by ‘git commit’. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
*
Any tips would be greatly appreciated!
I tried to run the experiment and expected it to run.

Meaning of Ynaqdhm?

I accidentally created a rails app that already exists (i.e. rails new existingapp)
The terminal says
Overwrite /Users/username/Desktop/existingapp/.gitignore? (enter "h" for help) [Ynaqdhm]
What does Ynaqdhm stand for? I guess they are the available options? (e.g. y: yes, n: no ?) I pressed a thinking it would mean abort, but the new app went ahead, so perhaps it meant all. Where can I find what this means
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
m - merge, run merge tool

Shift in the columns of spool file

I am using a shell script to extract the data from 'extr' table. The extr table is a very big table having 410 columns. The table has 61047 rows of data. The size of one record is around 5KB.
I the script is as follows:
#!/usr/bin/ksh
sqlplus -s \/ << rbb
set pages 0
set head on
set feed off
set num 20
set linesize 32767
set colsep |
set trimspool on
spool extr.csv
select * from extr;
/
spool off
rbb
#-------- END ---------
One fine day the extr.csv file was having 2 records with incorrect number of columns (i.e. one record with more number of columns and other with less). Upon investigation I came to know that the two duplicate records were repeated in the file. The primary key of the records should ideally be unique in file but in this case 2 records were repeated. Also, the shift in the columns was abrupt.
Small example of the output file:
5001|A1A|AAB|190.00|105|A
5002|A2A|ABB|180.00|200|F
5003|A3A|AAB|153.33|205|R
5004|A4A|ABB|261.50|269|F
5005|A5A|AAB|243.00|258|G
5006|A6A|ABB|147.89|154|H
5003|A7A|AAB|249.67|AAB|153.33|205|R
5004|A8A|269|F
5009|A9A|AAB|368.00|358|S
5010|AAA|ABB|245.71|215|F
Here the primary key records for 5003 and 5004 have reappeared in place of 5007 and 5008. Also the duplicate reciords have shifted the records of 5007 and 5008 by appending/cutting down their columns.
Need your help in analysing why this happened? Why the 2 rows were extracted multiple times? Why the other 2 rows were missing from the file? and Why the records were shifted?
Note: This script is working fine since last two years and has never failed except for one time (mentioned above). It ran successfully during next run. Recently we have added one more program which accesses the extr table with cursor (select only).
I reproduced a similar behaviour.
;-> cat input
5001|A1A|AAB|190.00|105|A
5002|A2A|ABB|180.00|200|F
5003|A3A|AAB|153.33|205|R
5004|A4A|ABB|261.50|269|F
5005|A5A|AAB|243.00|258|G
5006|A6A|ABB|147.89|154|H
5009|A9A|AAB|368.00|358|S
5010|AAA|ABB|245.71|215|F
See the input file as your database.
Now I write a script that accesses "the database" and show some random freezes.
;-> cat writeout.sh
# Start this script twice
while IFS=\| read a b c d e f; do
# I think you need \c for skipping \n, but I do it different one time
echo "$a|$b|$c|$d|" | tr -d "\n"
(( sleeptime = RANDOM % 5 ))
sleep ${sleeptime}
echo "$e|$f"
done < input >> output
EDIT: Removed cat input | in script above, replaced by < input
Start this script twice in the background
;-> ./writeout.sh &
;-> ./writeout.sh &
Wait until both jobs are finished and see the result
;-> cat output
5001|A1A|AAB|190.00|105|A
5002|A2A|ABB|180.00|200|F
5003|A3A|AAB|153.33|5001|A1A|AAB|190.00|105|A
5002|A2A|ABB|180.00|205|R
5004|A4A|ABB|261.50|269|F
5005|A5A|AAB|243.00|200|F
5003|A3A|AAB|153.33|258|G
5006|A6A|ABB|147.89|154|H
5009|A9A|AAB|368.00|358|S
5010|AAA|ABB|245.71|205|R
5004|A4A|ABB|261.50|269|F
5005|A5A|AAB|243.00|258|G
5006|A6A|ABB|147.89|215|F
154|H
5009|A9A|AAB|368.00|358|S
5010|AAA|ABB|245.71|215|F
When I edit the last line of writeout.sh into done > output I do not see the problem, but that might be due to buffering and the small amount of data.
I still don't know exactly what happened in your case, but it really seems like 2 progs writing simultaneously to the same script.
A job in TWS could have been restarted manually, 2 scripts in your masterscript might write to the same file or something else.
Preventing this in the future can be done using some locking / checks (when the output file exists, quit and return errorcode to TWS).

Run a PHP CRON Job on CPanel from a Different Timezone

I'm trying to run a PHP script from CRON every 15 minutes from 9AM to 6PM during Monday to Friday. My problem is the server is set to CST and my client is on GMT+8. I believe (please do correct me if I'm mistaken) we have a time difference of 13 hours. I'd like to check if the following settings are correct:
*/15 20-23 * * 2-7 wget -O - http://www.mysite.com/myscript.html
*/15 00-05 * * 2-7 wget -O - http://www.mysite.com/myscript.html
Pardon me. This is the first time I'm using CRON.
Thanks in advanced.
What you have looks OK except when daylight saving time changes occur. What will you do then? One option is to expand your window by an hour so that you run the job for an extra hour on one side during winter and the other side during summer. If that's not OK for some reason, you'll need to either change the server's timezone, change your script to check the time, or use this patch from OpenSolaris, which adds special TZ support to cron:
http://blogs.oracle.com/chrisg/entry/timezone_aware_cron_finally_pushed

Make Sphinx quiet (non-verbose)

I'm using Sphinx through Thinking Sphinx in a Ruby on Rails project. When I create seed data and all the time, it's quite verbose, printing this:
using config file '/Users/pupeno/projectx/config/development.sphinx.conf'...
indexing index 'user_delta'...
collected 7 docs, 0.0 MB
collected 0 attr values
sorted 0.0 Mvalues, 100.0% done
sorted 0.0 Mhits, 99.6% done
total 7 docs, 159 bytes
total 0.042 sec, 3749.29 bytes/sec, 165.06 docs/sec
Sphinx 0.9.8.1-release (r1533)
Copyright (c) 2001-2008, Andrew Aksyonoff
for every record that is created or so. Is there a way to suppress that output?
There is actually a setting to stop this - you'll want to set it at the end of your environment.rb file:
ThinkingSphinx.suppress_delta_output = true
In Thinking Sphinx v3 and newer, this has changed, and this setting is now managed through config/thinking_sphinx.yml. Repeat for each appropriate environment:
development:
quiet_deltas: true
Run sphinx with --quiet flag. I'm not using TS, though, so I don't know how to add make TS to use this flag. hth.

Resources