 -- ----------------------------
 DROP TABLE IF EXISTS "api"."message_reply";
 CREATE TABLE "api"."message_reply" (
-    "id" bigint NOT NULL DEFAULT nextval('api.message_reply_id_seq'::regclass),
-    "message_id" bigint NOT NULL DEFAULT 0,
-    "reply_id" bigint NOT NULL DEFAULT 0,
-    "meta_bits" smallint NOT NULL DEFAULT 0::smallint,
-    "created_at" timestamp(6) WITH TIME ZONE NOT NULL DEFAULT now()
-)
-WITH (OIDS=FALSE);
+    "id" BIGINT NOT NULL DEFAULT nextval(
+        'api.message_reply_id_seq' :: regclass
+    ),
+    "message_id" BIGINT NOT NULL DEFAULT 0,
+    "reply_id" BIGINT NOT NULL DEFAULT 0,
+    "meta_bits" SMALLINT NOT NULL DEFAULT 0 :: SMALLINT,
+    "created_at" TIMESTAMP (6) WITH TIME ZONE NOT NULL DEFAULT now()
+) WITH (OIDS = FALSE);
+
 -- ALTER TABLE "api"."message_reply" OWNER TO "socialapplication";
 GRANT SELECT, INSERT, DELETE ON "api"."message_reply" TO "socialapplication";


DROP TABLE IF EXISTS "api"."channel";
CREATE TABLE "api"."channel" (
    "id" bigint NOT NULL DEFAULT api.channel_next_id(),
    "name" varchar(200) NOT NULL COLLATE "default",
    "creator_id" bigint NOT NULL,
    "group_name" varchar(200) NOT NULL COLLATE "default",
    "purpose" text COLLATE "default",
    "secret_key" text COLLATE "default",
    "type_constant" "api"."channel_type_constant_enum",
    "privacy_constant" "api"."channel_privacy_constant_enum",
    "created_at" timestamp(6) WITH TIME ZONE NOT NULL DEFAULT now(),
    "updated_at" timestamp(6) WITH TIME ZONE NOT NULL DEFAULT now(),
    "deleted_at" timestamp(6) WITH TIME ZONE
)
WITH (OIDS=FALSE);
-- ALTER TABLE "api"."channel" OWNER TO "socialapplication";
GRANT SELECT, INSERT, UPDATE ON "api"."channel" TO "socialapplication";


    'chat',
    'privatemessage'
);

ALTER TYPE "api"."channel_message_type_constant_enum" OWNER TO "social";

DROP TABLE IF EXISTS "api"."channel_message";
CREATE TABLE "api"."channel_message" (
    "id" BIGINT NOT NULL DEFAULT api.channel_message_next_id (),
    "body" TEXT COLLATE "default",
    "slug" VARCHAR (100) NOT NULL COLLATE "default",
    "type_constant" "api"."channel_message_type_constant_enum",
    "account_id" BIGINT NOT NULL,
    "initial_channel_id" BIGINT NOT NULL,
    "meta_bits" SMALLINT NOT NULL DEFAULT 0 :: SMALLINT,
    "created_at" TIMESTAMP (6) WITH TIME ZONE NOT NULL DEFAULT now(),
    "updated_at" TIMESTAMP (6) WITH TIME ZONE NOT NULL DEFAULT now(),
    "deleted_at" TIMESTAMP (6) WITH TIME ZONE,
    "payload" hstore
) WITH (OIDS = FALSE);

-- ALTER TABLE "api"."channel_message" OWNER TO "socialapplication";
GRANT SELECT, INSERT, UPDATE ON "api"."channel_message" TO "socialapplication";

