#This script attempts to upgrade a database from version 0.4-devel to the current version

ALTER TABLE user ADD COLUMN reminders CHAR(1) DEFAULT 'y';

ALTER TABLE user ADD COLUMN private_email CHAR(1) DEFAULT 'n';

CREATE TABLE pending (
	seller_uid INTEGER,
	bid INTEGER,
	buyer_uid INTEGER,
	buyer_name VARCHAR(90),
	buyer_email VARCHAR(45),
	remote_addr VARCHAR(15),
	date TIMESTAMP(8)
);

CREATE TABLE contact (
	cid INTEGER AUTO_INCREMENT PRIMARY KEY,
	date TIMESTAMP(8),
	uid INTEGER,
	name VARCHAR(90),
	email VARCHAR(45),
	message TEXT
);


# Changes from 0.8
ALTER TABLE user ADD COLUMN new_pass VARCHAR(32);

ALTER TABLE user ADD COLUMN p_salt VARCHAR(32);

UPDATE user set p_salt = md5(CONCAT(user,rand(now())));

UPDATE user set new_pass = md5(CONCAT(password,p_salt));

ALTER TABLE user DROP COLUMN password;

ALTER TABLE user CHANGE new_pass password VARCHAR(32);

ALTER TABLE user ADD COLUMN pass_reset VARCHAR(16);

ALTER TABLE book CHANGE isbn isbn VARCHAR(13);
