diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt new file mode 100644 index 0000000000000..fe3c40342da6b --- /dev/null +++ b/SQL/database_changelog.txt @@ -0,0 +1,15 @@ +4 November 2013, by Errorage + +The column 'deleted' was added to the erro_library table. If set to anything other than null, the book is interpreted as deleted. + +To update your database, execute the following code in phpmyadmin, mysql workbench or whatever program you use: + +ALTER TABLE erro_library ADD COLUMN deleted TINYINT(1) NULL DEFAULT NULL AFTER datetime; + +If you want to 'soft delete' a book (meaning it remains in the library, but isn't viewable by players), set the value in the 'deleted' column for the row to 1. To undelete, set it back to null. If you're making an admin tool to work with this, execute the following SQL statement to soft-delete the book with id someid: + +UPDATE erro_library SET deleted = 1 WHERE id = someid + +(Replace someid with the id of the book you want to soft delete.) + +---------------------------------------------------- \ No newline at end of file diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql index 4b470f05063ac..b6ec2ba35e855 100644 --- a/SQL/tgstation_schema.sql +++ b/SQL/tgstation_schema.sql @@ -174,6 +174,7 @@ CREATE TABLE `erro_library` ( `category` varchar(45) NOT NULL, `ckey` varchar(45) DEFAULT 'LEGACY', `datetime` datetime DEFAULT NULL, + `deleted` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index fd516498b41fe..16e4dd7dcdb8f 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -98,7 +98,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f author = null author = sanitizeSQL(author) if(href_list["search"]) - SQLquery = "SELECT author, title, category, id FROM erro_library WHERE " + SQLquery = "SELECT author, title, category, id FROM erro_library WHERE isnull(deleted) AND " if(category == "Any") SQLquery += "author LIKE '%[author]%' AND title LIKE '%[title]%'" else @@ -201,7 +201,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f dat += "" dat += "" - var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM erro_library") + var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM erro_library WHERE isnull(deleted)") query.Execute() while(query.NextRow()) @@ -370,7 +370,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f bibledelay = 1 spawn(60) bibledelay = 0 - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM erro_library WHERE id=[sqlid]") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM erro_library WHERE id=[sqlid] AND isnull(deleted)") query.Execute() while(query.NextRow())
AUTHORTITLECATEGORY