Try to cast TEXT typed updated_at and created_at if present

If the cast fails we'll still rename those fields and create
new ones. See #27 (cartodb_id is still not done)
This commit is contained in:
Sandro Santilli
2014-05-22 13:10:42 +02:00
parent 75a40c9b63
commit 134d2d29b6
3 changed files with 32 additions and 21 deletions

View File

@@ -170,6 +170,14 @@ SELECT CDB_CartodbfyTableCheck('t', 'trigger-protected the_geom');
SELECT 'extent',ST_Extent(ST_SnapToGrid(the_geom,0.1)) FROM t;
DROP TABLE t;
-- table with existing updated_at and created_at fields ot type text
CREATE TABLE t AS SELECT NOW()::text as created_at,
NOW()::text as updated_at,
NOW() as reftime;
SELECT CDB_CartodbfyTableCheck('t', 'text timestamps');
SELECT reftime-created_at, reftime-updated_at FROM t;
DROP TABLE t;
-- TODO: table with existing custom-triggered the_geom
DROP FUNCTION CDB_CartodbfyTableCheck(regclass, text);

View File

@@ -25,5 +25,9 @@ CREATE TRIGGER
trigger-protected the_geom cartodbfied fine
extent|BOX(1 1,2 2)
DROP TABLE
SELECT 1
text timestamps cartodbfied fine
@ 0|@ 0
DROP TABLE
DROP FUNCTION
DROP FUNCTION