-- ipfon_sms_deliv_log
DROP TABLE IF EXISTS "ipfon_sms_deliv_log";
DROP SEQUENCE IF EXISTS "ipfon_sms_deliv_log_id_seq";

-- ipfon_sms_deliv_queue
DROP TABLE IF EXISTS "ipfon_sms_deliv_queue";
DROP SEQUENCE IF EXISTS "ipfon_sms_deliv_queue_id_seq";

-- ipfon_sms_out_log
DROP INDEX "ipfon_sms_out_log_id_idx";
DROP INDEX "ipfon_sms_out_log_local_id_idx";
DROP INDEX "ipfon_sms_out_log_msg_id_idx";
DROP INDEX "ipfon_sms_out_log_remote_id_idx";
DROP INDEX "ipfon_sms_out_log_src_account_id";
DROP INDEX "ipfon_sms_out_log_src_account_type";
DROP INDEX "ipfon_sms_out_log_src_proto";

ALTER TABLE "ipfon_sms_out_log"
DROP "refno",
DROP "src_account_id",
DROP "src_account_type",
DROP "src_proto",
DROP "all_parts_exists",
DROP "local_id",
DROP "retries",
DROP "id";

DROP SEQUENCE IF EXISTS "ipfon_sms_out_log_id_seq";
DROP SEQUENCE IF EXISTS "ipfon_sms_local_id_seq";
DROP SEQUENCE IF EXISTS "ipfon_sms_msg_id_seq";

ALTER TABLE "ipfon_sms_out_log" RENAME COLUMN "msg_id" TO "id";

-- ipfon_sms_out_queue
ALTER TABLE "ipfon_sms_out_queue"
DROP "parts",
DROP "partno",
DROP "refno",
DROP "src_account_id",
DROP "src_account_type",
DROP "src_proto",
DROP "id",
DROP "local_id";

ALTER TABLE "ipfon_sms_out_queue" RENAME COLUMN "msg_id" TO "id";
ALTER TABLE "ipfon_sms_out_queue" ALTER COLUMN "id" SET DEFAULT nextval('ipfon_sms_out_queue_id_seq');

-- ipfon_sms_test_log
ALTER TABLE "ipfon_sms_test_log"
DROP "src",
DROP "dst",
DROP "dst_icpoint";

-- ipfon_sms_account
ALTER TABLE "ipfon_sms_account"
DROP "max_connections";