sql/update-*-v2.sql: Scripts to upgrade existing database schemata.
[odin-cgi] / sql / update-shorturl-v2.sql
diff --git a/sql/update-shorturl-v2.sql b/sql/update-shorturl-v2.sql
new file mode 100644 (file)
index 0000000..2165d62
--- /dev/null
@@ -0,0 +1,15 @@
+/* -*-sql-*-
+ *
+ * Plain old SQL for setting up the tables for Odin web services.
+ */
+
+begin;
+alter table odin_shorturl rename column stamp to oldstamp;
+alter table odin_shorturl add column stamp bigint not null default 0;
+update odin_shorturl set stamp = extract(epoch from oldstamp);
+commit;
+
+begin;
+alter table odin_shorturl drop column oldstamp;
+alter table odin_shorturl alter column stamp drop default;
+commit;