-- SQL file to strip out private informations from wwwtest.ubuntu-it.org
-- database that should be not around on developer systems, disable modules
-- that shouldn't be enabled and set admin password to one easy to use for
-- developing purposes
--
-- All our tables have 'drupal' as prepend
--
-- Copyright (C) 2014 Riccardo Padovani <riccardo@rpadovani.com>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

-- In drupal_authname there are all users authentication names.
-- We use OpenID, so there are only links to OpenID profiles.
-- If classic authentication is used, decomment the following lines
-- UPDATE drupal_authmap SET authname = CONCAT(aid, '@localhost');

-- In drupal_users there are some interesting informations:
-- Anyway, we don't want to use in local same users we use on test server,
-- because we disable OpenID module, otherwise no one could access but
-- ubuntu-it-www members
-- So we truncate the table and insert a new admin user with pass admin
TRUNCATE drupal_users;
INSERT INTO drupal_users(uid, name, pass, mail, timezone, language, status, init)
VALUES (1, 'admin', '434c3264048726754ee0e07e508d867e', 'admin@localhost', 'Europe/Berlin', 'it', 1, 'admin@localhost');

-- Turnoff modules
DELETE FROM drupal_system WHERE name IN ('tweet_button', 'openid_test', 'openid_launchpad', 'openid_teams', 'googleanalytics', 'google_plusone', 'openid', 'fblikebutton', 'disqus');

-- Delete emails from comments
UPDATE drupal_comment SET name='Anonymous', mail='anonymous@localhost', homepage='http://www.ubuntu-it.org' WHERE uid=0;

-- Truncate tables with sensitive data
TRUNCATE drupal_authmap;
TRUNCATE drupal_cache;
TRUNCATE drupal_cache_block;
TRUNCATE drupal_cache_bootstrap;
TRUNCATE drupal_cache_field;
TRUNCATE drupal_cache_filter;
TRUNCATE drupal_cache_form;
TRUNCATE drupal_cache_image;
TRUNCATE drupal_cache_l10n_update;
TRUNCATE drupal_cache_menu;
TRUNCATE drupal_cache_page;
TRUNCATE drupal_cache_panels;
TRUNCATE drupal_cache_path;
TRUNCATE drupal_cache_token;
TRUNCATE drupal_cache_update;
TRUNCATE drupal_cache_views;
TRUNCATE drupal_cache_views_data; 
TRUNCATE drupal_disqus;
TRUNCATE drupal_flood;
TRUNCATE drupal_history;
TRUNCATE drupal_openid_association;
TRUNCATE drupal_openid_nonce;
TRUNCATE drupal_openid_teams_roles;
TRUNCATE drupal_openid_teams_trusted;
TRUNCATE drupal_search_dataset;
TRUNCATE drupal_search_index;
TRUNCATE drupal_search_node_links;
TRUNCATE drupal_search_total;
TRUNCATE drupal_sessions;
TRUNCATE drupal_watchdog;

-- Delete sensitive variables
DELETE FROM drupal_variable WHERE name IN ('drupal_secret_key', 'cron_key');
DELETE FROM drupal_variable WHERE name LIKE 'openid_%';
DELETE FROM drupal_variable WHERE name LIKE 'disqus_%';
