User:Aaron Schulz/deletion

On delete, move `page` entry to `deleted_pages` and set rev_deleted to 1+2+4 = 7 for all revisions rows to add a layer of protection.

 -- -- Holding area for deleted pages -- CREATE TABLE /*$wgDBprefix*/deleted_pages ( -- Unique identifier number. The page_id will be preserved across  -- edits and rename operations.  deleted_page_id int unsigned NOT NULL auto_increment,  -- A page name is broken into a namespace and a title.  -- The namespace keys are UI-language-independent constants,  -- defined in includes/Defines.php  deleted_page_namespace int NOT NULL,  -- The rest of the title, as text.  -- Spaces are transformed into underscores in title storage.  deleted_page_title varchar(255) binary NOT NULL,  -- Random value between 0 and 1, used for Special:Randompage  deleted_page_random real unsigned NOT NULL,  -- Timestamp of the last page deletion  deleted_on_timestamp binary(14) NOT NULL default '',

PRIMARY KEY deleted_page_id (deleted_page_id), UNIQUE INDEX name_title (deleted_page_namespace,deleted_page_title), ) /*$wgDBTableOptions*/; 

On restore, move back to `page` and fill in other columns based on the last rev. Remove rev_deleted for restored revs.