{
$user = is_null($uid) ? S::v('uid') : $uid;
XDB::execute("REPLACE INTO newsletter_ins (uid,last)
- VALUES ({?}, 0)", $user);
+ VALUES ({?}, NULL)", $user);
}
protected function subscriptionWhere()
XDB::execute("UPDATE profiles
SET section = {?}
WHERE pid = {?}",
- $value, $page->pid());
+ ($value == 0) ? null : $value, $page->pid());
}
public function getText($value) {
public function vote($uid, $args)
{
XDB::execute('INSERT INTO survey_votes
- SET survey_id = {?}, uid = {?};', $this->id, $uid); // notes the user as having voted
+ SET survey_id = {?}, uid = {?}',
+ $this->id, ($uid == 0) ? null : $uid); // notes the user as having voted
$vid = XDB::insertId();
for ($i = 0; $i < count($this->questions); $i++) {
$ans = $this->questions[$i]->checkAnswer($args[$i]);
UPDATE register_mstats SET sender = NULL WHERE sender = 0;
UPDATE requests SET pid = NULL WHERE pid = 0;
UPDATE profile_addresses SET pid = NULL WHERE pid = 0;
+UPDATE survey_votes SET uid = NULL WHERE uid = 0;
-- Deltes erroneous data.
DELETE FROM homonyms WHERE NOT EXISTS (SELECT * FROM accounts WHERE accounts.uid = homonyms.homonyme_id);
DELETE FROM watch WHERE NOT EXISTS (SELECT * FROM accounts WHERE accounts.uid = watch.uid);
DELETE FROM group_event_participants WHERE NOT EXISTS (SELECT * FROM accounts WHERE accounts.uid = group_event_participants.uid);
DELETE FROM group_members WHERE NOT EXISTS (SELECT * FROM accounts WHERE accounts.uid = group_members.uid);
+DELETE FROM axletter_ins WHERE NOT EXISTS (SELECT * FROM accounts WHERE accounts.uid = axletter_ins.uid);
-- Following tables all refer to accounts.uid.
ALTER TABLE account_auth_openid ADD FOREIGN KEY (uid) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE;
-- Following tables all refer to accounts.uid, but they use a different name.
ALTER TABLE contacts ADD FOREIGN KEY (contact) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE;
-ALTER TABLE email_list_moderate ADD FOREIGN KEY (mid) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE gapps_accounts ADD FOREIGN KEY (l_userid) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE gapps_queue ADD FOREIGN KEY (q_owner_id) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE gapps_queue ADD FOREIGN KEY (q_recipient_id) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE;
UPDATE profile_education_enum SET country = NULL WHERE country = '';
UPDATE profile_job SET jobid = NULL WHERE jobid = 0;
UPDATE profile_job_enum SET holdingid = NULL WHERE holdingid = 0;
+UPDATE profiles SET section = NULL WHERE section = 0;
-- Adds missing data in foreign tables.
INSERT INTO geoloc_countries (iso_3166_1_a2, iso_3166_1_a3, iso_3166_1_num, worldRegion, country,
UPDATE groups SET dom = NULL WHERE dom = 0;
UPDATE payments SET asso_id = NULL WHERE asso_id = 0;
UPDATE newsletter_art SET cid = NULL WHERE cid = 0;
+UPDATE newsletter_ins SET last = NULL WHERE last = 0;
-- Deletes things that should have been deleted ealier.
DELETE FROM newsletter_art WHERE NOT EXISTS (SELECT * FROM newsletter WHERE newsletter.id = newsletter_art.id);
oldText TEXT NOT NULL,
newText TEXT NOT NULL,
pub ENUM('private', 'ax', 'public') NOT NULL DEFAULT 'private',
- PRIMARY KEY(pid, uid, field)
+ PRIMARY KEY(pid, uid, field),
FOREIGN KEY (uid) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (pid) REFERENCES profiles (pid) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB, CHARSET=utf8;
. ../inc/pervasive.sh
###########################################################
-[ "$DATABASE" != "x5dat" ] || die "Cannot target x5dat"
+[ "$DATABASE" != "x4dat" ] || die "Cannot target x4dat"
copy_db
echo "* switching engines to InnoDB"
-(./innodb.sh | while read line; do mysql_exec "$line"; done) || die "ERROR"
-echo "OK"
+./innodb.sh | mysql_pipe
confirm "* Running database upgrade scripts"
mysql_run_directory .