common/dal/schema/000018_init.up.sql

20 lines
630 B
MySQL
Raw Normal View History

2024-06-27 19:15:13 +00:00
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'tgAccountStatus') THEN
CREATE TYPE TgAccountStatus AS ENUM ('active', 'inactive', 'ban');
END IF;
END $$;
CREATE TABLE IF NOT EXISTS tgAccounts (
id bigserial primary key ,
ApiID integer not null,
ApiHash text not null ,
PhoneNumber text not null ,
2024-06-27 19:40:42 +00:00
Password text not null ,
2024-06-27 19:15:13 +00:00
Status TgAccountStatus not null,
Deleted bool not null default false,
CreatedAt timestamp not null default current_timestamp
2024-07-01 13:08:20 +00:00
);
CREATE UNIQUE INDEX idx_apiid_apihash ON tgAccounts (ApiID, ApiHash) WHERE Deleted = false;