ALTER TABLE genre_lst RENAME TO genre;
ALTER TABLE genre RENAME COLUMN genre TO name;

CREATE TABLE condition (
	id     INTEGER,
	name   VARCHAR(20) not null, 
	constraint pk_condition primary key(id)
);
INSERT INTO condition VALUES ( 1, 'Good' );
INSERT INTO condition VALUES ( 2, 'Average' );
INSERT INTO condition VALUES ( 3, 'Needs Replacing' );
INSERT INTO condition VALUES ( 4, 'N/A' );
ALTER TABLE book ADD COLUMN temp_cond integer , ADD CONSTRAINT fk_book_condition_new foreign key(temp_cond) REFERENCES condition(id)

CREATE TABLE covertype (
	id     INTEGER,
	name   VARCHAR(20) not null, 
	constraint pk_covertype primary key(id)
);
INSERT INTO covertype VALUES ( 1, 'Paperback' );
INSERT INTO covertype VALUES ( 2, 'Over-size Paperback' );
INSERT INTO covertype VALUES ( 3, 'Hardcover' );
INSERT INTO covertype VALUES ( 4, 'N/A' );
ALTER TABLE book ADD COLUMN temp_cover integer , ADD CONSTRAINT fk_book_covertype_new foreign key(temp_cover) REFERENCES covertype(id)

CREATE TABLE owned (
	id     INTEGER,
	name   VARCHAR(20) not null, 
	constraint pk_owned primary key(id)
);
INSERT INTO owned VALUES ( 1, 'Currently Owned' );
INSERT INTO owned VALUES ( 2, 'On Wish List' );
INSERT INTO owned VALUES ( 3, 'Sold' );
ALTER TABLE book ADD COLUMN temp_owned integer , ADD CONSTRAINT fk_book_owned_new foreign key(temp_owned) REFERENCES owned(id);

CREATE TABLE rating (
	id     INTEGER,
	name   VARCHAR(20) not null, 
	constraint pk_rating primary key(id)
);
INSERT INTO rating VALUES ( 1, '10' );
INSERT INTO rating VALUES ( 2, '9' );
INSERT INTO rating VALUES ( 3, '8' );
INSERT INTO rating VALUES ( 4, '7' );
INSERT INTO rating VALUES ( 5, '6' );
INSERT INTO rating VALUES ( 6, '5' );
INSERT INTO rating VALUES ( 7, '4' );
INSERT INTO rating VALUES ( 8, '3' );
INSERT INTO rating VALUES ( 9, '2' );
INSERT INTO rating VALUES ( 10, '1' );
INSERT INTO rating VALUES ( 11, 'N/A' );
INSERT INTO rating VALUES ( 12, 'Undefined' );
ALTER TABLE book ADD COLUMN temp_rating integer, ADD CONSTRAINT fk_book_rating_new foreign key(temp_rating) REFERENCES rating(id);


### fore each new table (e.g do above), then
# add appropriate new field to Book class definition, eg for condition:
temp_cond = db.Column(db.Integer)

# then run python code with fix_db() -- which fixes appropriate Book.<new_field>, then:

ALTER TABLE book DROP COLUMN condition;
ALTER TABLE book RENAME COLUMN temp_cond TO condition;

ALTER TABLE book DROP COLUMN covertype;
ALTER TABLE book RENAME COLUMN temp_cover TO covertype;

ALTER TABLE book DROP COLUMN owned;
ALTER TABLE book RENAME COLUMN temp_owned TO owned;

ALTER TABLE book DROP COLUMN rating;
ALTER TABLE book RENAME COLUMN temp_rating TO rating;

DROP TABLE condition_lst;
DROP TABLE covertype_lst;
DROP TABLE owned_lst;
DROP TABLE rating_lst;

# then modify main.py again, to delete condition and rename temp_<field> to <feild> in class Book
