/* -*-sql-*-
 *
 * Plain old SQL for setting up the tables for Odin web services.
 *
 * (c) 2015 Mark Wooding
 */

/*----- Licensing notice ----------------------------------------------------
 *
 * This file is part of the `odin.gg' service, `odin-cgi'.
 *
 * `odin-cgi' is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * `odin-cgi' 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with `odin-cgi'; if not, see
 * <http://www.gnu.org/licenses/>.
 */

begin;
alter table odin_pastebin alter column lang set default 'txt';
alter table odin_pastebin rename column stamp to oldstamp;
alter table odin_pastebin add column stamp bigint not null default 0;
update odin_pastebin set stamp = extract(epoch from oldstamp);
commit;

begin;
alter table odin_pastebin drop column oldstamp;
alter table odin_pastebin alter column stamp drop default;
commit;
