:VERSION 1         # -------------------------- 

BEGIN Transaction;

Create Sequence im_offiline_id increment by 1 start with 1;

CREATE TABLE im_offline (
  "ID" integer PRIMARY KEY NOT NULL DEFAULT nextval('im_offiline_id') ,
  "PrincipalID" char(36) NOT NULL default '',
  "Message" text NOT NULL,
  "TMStamp" timestamp NOT NULL default now()
);

COMMIT;

:VERSION 2         # -------------------------- 

BEGIN;

/*
INSERT INTO `im_offline` SELECT * from `diva_im_offline`;
DROP TABLE `diva_im_offline`;
DELETE FROM `migrations` WHERE name='diva_im_Store';
*/

COMMIT;

:VERSION 3         # -------------------------- 

BEGIN;

-- dropping the table here as there most likely is only one record in the table at the time of migration

DROP TABLE IF EXISTS "public"."im_offline";
CREATE TABLE "public"."im_offline" (
	"ID" serial,
	"PrincipalID" uuid NOT NULL,
	"Message" text NOT NULL COLLATE "default",
	"TMStamp" timestamp(6) NOT NULL DEFAULT clock_timestamp(),
	"FromID" uuid NOT NULL
)
WITH (OIDS=FALSE);
ALTER TABLE "public"."im_offline" ADD PRIMARY KEY ("ID","PrincipalID","FromID") NOT DEFERRABLE INITIALLY IMMEDIATE;

COMMIT;