File: 200403252.sql

package info (click to toggle)
fusionforge 5.3.2%2B20141104-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 60,472 kB
  • sloc: php: 271,846; sql: 36,817; python: 14,575; perl: 6,406; sh: 5,980; xml: 4,294; pascal: 1,411; makefile: 911; cpp: 52; awk: 27
file content (18 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ALTER TABLE users ADD COLUMN theme_id INT;
--ALTER TABLE users ALTER COLUMN theme_id SET DEFAULT NOT NULL 1;
--UPDATE users SET theme_id=1
--	WHERE NOT EXISTS (select user_theme FROM theme_prefs WHERE user_id=users.user_id);
UPDATE users SET theme_id=
	(select user_theme FROM theme_prefs WHERE user_id=users.user_id)
	WHERE EXISTS (select user_theme FROM theme_prefs WHERE user_id=users.user_id);
--
--	If there is no theme_id=1 in the themes table, we could have a problem
--
UPDATE users SET theme_id=(SELECT min(theme_id) FROM themes WHERE enabled=true LIMIT 1)
	WHERE theme_id IS NULL;
ALTER TABLE users ADD CONSTRAINT users_themeid
        FOREIGN KEY (theme_id) REFERENCES themes(theme_id) MATCH FULL;
ALTER TABLE users ADD CONSTRAINT users_ccode
        FOREIGN KEY (ccode) REFERENCES country_code(ccode) MATCH FULL;
DROP TABLE theme_prefs;