if [ "$1" ]; then
echo "$1"
elif [ "$TYPE_FILES" = "a" ]; then
- echo sql.d/[0-9]*
+ find sql.d/ -name '[0-9]*' -type f | tr '\n' ' '
elif [ "$TYPE_FILES" = "d" ]; then
- echo sql.d/[0-9]*.{sql,devel}
+ find sql.d/ -name '[0-9]*' | egrep '.*_devel.sql$|^[^_]+.sql$' | tr '\n' ' '
else
- echo sql.d/[0-9]*.sql
- fi); do
+ find sql.d/ -name '[0-9]*' | egrep '^[^_]+.sql$' | tr '\n' ' '
+ fi); do
echo "-- FILE BEG: $fil"
cat "$fil"
echo "-- FILE END: $fil"
+++ /dev/null
-DELETE FROM #PFX#bin5_matches WHERE code = 100 OR code = 101;
-
-INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (100, 'normalize_points', 2, 1, 1) RETURNING *;
-INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10101, 0);
-INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10102, 1);
-INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10103, 2);
-INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
- VALUES (200, 100, to_timestamp(#NOW# - 1000), 2, 60, 0, -1, -1, 0, 0) RETURNING *;
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10101, 0);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10102, 0);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10103, 0);
-UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100;
-INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
- VALUES (201, 100, to_timestamp(#NOW# - 900), 0, 61, 37, 2, 1, 1, 1) RETURNING *;
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10101, 2);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10102, -2);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10103, -4);
-
-
-INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (101, 'normalize_points2', 2, 1, 0) RETURNING *;
-INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10101, 0);
-INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10102, 1);
-INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10103, 2);
-INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
- VALUES (202, 101, to_timestamp(#NOW# - 800), 2, 60, 0, -1, -1, 0, 0) RETURNING *;
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10101, 0);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10102, 0);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10103, 0);
-UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100;
-INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
- VALUES (203, 101, to_timestamp(#NOW# - 700), 0, 81, 37, 2, 1, 1, 1) RETURNING *;
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10101, 6);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10102, -6);
-INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10103, -12);
-
-
-
--- /dev/null
+DELETE FROM #PFX#bin5_matches WHERE code = 100 OR code = 101;
+
+INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (100, 'normalize_points', 2, 1, 1) RETURNING *;
+INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10101, 0);
+INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10102, 1);
+INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10103, 2);
+INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
+ VALUES (200, 100, to_timestamp(#NOW# - 1000), 2, 60, 0, -1, -1, 0, 0) RETURNING *;
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10101, 0);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10102, 0);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10103, 0);
+UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100;
+INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
+ VALUES (201, 100, to_timestamp(#NOW# - 900), 0, 61, 37, 2, 1, 1, 1) RETURNING *;
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10101, 2);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10102, -2);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10103, -4);
+
+
+INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (101, 'normalize_points2', 2, 1, 0) RETURNING *;
+INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10101, 0);
+INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10102, 1);
+INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10103, 2);
+INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
+ VALUES (202, 101, to_timestamp(#NOW# - 800), 2, 60, 0, -1, -1, 0, 0) RETURNING *;
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10101, 0);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10102, 0);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10103, 0);
+UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100;
+INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult)
+ VALUES (203, 101, to_timestamp(#NOW# - 700), 0, 81, 37, 2, 1, 1, 1) RETURNING *;
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10101, 6);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10102, -6);
+INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10103, -12);
+
+
+
+++ /dev/null
---
--- Populate users db.
---
-
--- macro for user_flag bit-field
--- define('USER_FLAG_TY_ALL', 0xff0000); // done
--- define('USER_FLAG_TY_NORM', 0x010000); // done
--- define('USER_FLAG_TY_SUPER', 0x020000); // done
--- define('USER_FLAG_TY_CERT', 0x040000); // done
--- define('USER_FLAG_TY_APPR', 0x080000); // done
--- define('USER_FLAG_TY_FIRONLY', 0x200000); // done
--- define('USER_FLAG_TY_ADMIN', 0x400000); // done
--- define('USER_FLAG_TY_DISABLE', 0x800000); // done
-
-
-DELETE FROM #PFX#users WHERE code = 10101;
-DELETE FROM #PFX#users WHERE guar_code = 10101 AND code != 10101;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10101, 'uno', md5('one'), 'uno@pluto.com', CAST (X'00450000' as integer), 10101);
-DELETE FROM #PFX#users WHERE code = 10102;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10102, 'due', md5('two'), 'due@pluto.com', CAST (X'00010000' as integer), 10101);
-DELETE FROM #PFX#users WHERE code = 10103;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10103, 'tre', md5('thr'), 'tre@pluto.com', CAST (X'00030000' as integer), 10102);
-DELETE FROM #PFX#users WHERE code = 10104;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10104, 'qua', md5('for'), 'qua@pluto.com', CAST (X'00010000' as integer), 10102);
-DELETE FROM #PFX#users WHERE code = 10105;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10105, 'cin', md5('fiv'), 'cin@pluto.com', CAST (X'00010000' as integer), 10103);
-DELETE FROM #PFX#users WHERE code = 10106;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10106, 'sei', md5('six'), 'sei@pluto.com', CAST (X'00210000' as integer), 10103);
-DELETE FROM #PFX#users WHERE code = 10107;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10107, E'"/\\''|', md5('sev'), 'sev@pluto.com', CAST (X'00210000' as integer), 10103);
-DELETE FROM #PFX#users WHERE code = 10108;
-INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10108, E'appr', md5('appr'), 'appr@pluto.com', CAST (X'00080000' as integer), 10103);
-ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10109;
--- /dev/null
+--
+-- Populate users db.
+--
+
+-- macro for user_flag bit-field
+-- define('USER_FLAG_TY_ALL', 0xff0000); // done
+-- define('USER_FLAG_TY_NORM', 0x010000); // done
+-- define('USER_FLAG_TY_SUPER', 0x020000); // done
+-- define('USER_FLAG_TY_CERT', 0x040000); // done
+-- define('USER_FLAG_TY_APPR', 0x080000); // done
+-- define('USER_FLAG_TY_FIRONLY', 0x200000); // done
+-- define('USER_FLAG_TY_ADMIN', 0x400000); // done
+-- define('USER_FLAG_TY_DISABLE', 0x800000); // done
+
+
+DELETE FROM #PFX#users WHERE code = 10101;
+DELETE FROM #PFX#users WHERE guar_code = 10101 AND code != 10101;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10101, 'uno', md5('one'), 'uno@pluto.com', CAST (X'00450000' as integer), 10101);
+DELETE FROM #PFX#users WHERE code = 10102;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10102, 'due', md5('two'), 'due@pluto.com', CAST (X'00010000' as integer), 10101);
+DELETE FROM #PFX#users WHERE code = 10103;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10103, 'tre', md5('thr'), 'tre@pluto.com', CAST (X'00030000' as integer), 10102);
+DELETE FROM #PFX#users WHERE code = 10104;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10104, 'qua', md5('for'), 'qua@pluto.com', CAST (X'00010000' as integer), 10102);
+DELETE FROM #PFX#users WHERE code = 10105;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10105, 'cin', md5('fiv'), 'cin@pluto.com', CAST (X'00010000' as integer), 10103);
+DELETE FROM #PFX#users WHERE code = 10106;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10106, 'sei', md5('six'), 'sei@pluto.com', CAST (X'00210000' as integer), 10103);
+DELETE FROM #PFX#users WHERE code = 10107;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10107, E'"/\\''|', md5('sev'), 'sev@pluto.com', CAST (X'00210000' as integer), 10103);
+DELETE FROM #PFX#users WHERE code = 10108;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10108, E'appr', md5('appr'), 'appr@pluto.com', CAST (X'00080000' as integer), 10103);
+ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10109;
+++ /dev/null
--- primary owner 10101
-DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10102;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10102, 4, 2, 5);
-DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10103;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10103, 5, 2, 3);
--- primary owner: discarded target
-DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10104;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10104, 1, 2, 5);
-
--- secondary owners for 10101
-DELETE FROM #PFX#usersnet WHERE owner = 10102 AND inher = 10102 AND target = 10105;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10102, 10102, 10105, 4, 2, 3);
-DELETE FROM #PFX#usersnet WHERE owner = 10103 AND inher = 10103 AND target = 10105;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10103, 10103, 10105, 4, 3, 4);
-DELETE FROM #PFX#usersnet WHERE owner = 10104 AND inher = 10104 AND target = 10105;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10104, 10104, 10105, 4, 5, 4);
-
-DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10107;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10107, 3, 3, 4);
-DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher is NULL AND target = 10107;
-INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, NULL, 10107, 3, 3, 4);
-
-SELECT * FROM bsk_usersnet_wideskill;
-SELECT * FROM bsk_usersnet_narrowskill;
-
--- /dev/null
+-- primary owner 10101
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10102;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10102, 4, 2, 5);
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10103;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10103, 5, 2, 3);
+-- primary owner: discarded target
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10104;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10104, 1, 2, 5);
+
+-- secondary owners for 10101
+DELETE FROM #PFX#usersnet WHERE owner = 10102 AND inher = 10102 AND target = 10105;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10102, 10102, 10105, 4, 2, 3);
+DELETE FROM #PFX#usersnet WHERE owner = 10103 AND inher = 10103 AND target = 10105;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10103, 10103, 10105, 4, 3, 4);
+DELETE FROM #PFX#usersnet WHERE owner = 10104 AND inher = 10104 AND target = 10105;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10104, 10104, 10105, 4, 5, 4);
+
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10107;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10107, 3, 3, 4);
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher is NULL AND target = 10107;
+INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, NULL, 10107, 3, 3, 4);
+
+SELECT * FROM bsk_usersnet_wideskill;
+SELECT * FROM bsk_usersnet_narrowskill;
+