BEGIN TRANSACTION;

ALTER TABLE gift RENAME TO wish;

ALTER TABLE user ADD COLUMN display_name TEXT NOT NULL DEFAULT "";

UPDATE user SET display_name = name;

ALTER TABLE user RENAME TO old_user;

CREATE TABLE "user" (
	"id"	INTEGER NOT NULL UNIQUE,
	"name"	TEXT NOT NULL UNIQUE,
	"display_name"	TEXT NOT NULL UNIQUE,
	"reference"	TEXT NOT NULL UNIQUE,
	"motto"	TEXT NOT NULL DEFAULT "",
	"password_hash"	TEXT NOT NULL,
	"is_admin" INTEGER NOT NULL DEFAULT 0,
	"is_live" INTEGER NOT NULL DEFAULT 1,
	PRIMARY KEY("id" AUTOINCREMENT)
);

INSERT INTO user (id, name, display_name, reference, motto, password_hash, is_admin, is_live) SELECT id, name, name, reference, motto, password_hash, is_admin, is_live FROM old_user;

DROP TABLE "old_user";

COMMIT;

