move function and trigger creation in ddl.sql

Context is in https://github.com/QueueClassic/queue_classic/issues/233
rename variable in QC Setup
add Rails migration
Merge branch 'fix-upgrade' into 3-0-stable