add new mig files and some queries
This commit is contained in:
parent
0bf45822a6
commit
99008ff193
@ -1067,3 +1067,10 @@ UPDATE leadtarget SET target = $1 WHERE id = $2 AND deleted=false RETURNING *;
|
|||||||
|
|
||||||
-- name: GetLeadTarget :many
|
-- name: GetLeadTarget :many
|
||||||
SELECT * FROM leadtarget WHERE accountID = $1 AND quizID = $2 AND deleted=false;
|
SELECT * FROM leadtarget WHERE accountID = $1 AND quizID = $2 AND deleted=false;
|
||||||
|
|
||||||
|
-- name: CreateTgAccount :one
|
||||||
|
INSERT INTO tgAccounts (ApiID, ApiHash, PhoneNumber, Status)
|
||||||
|
VALUES ($1, $2, $3, $4) RETURNING id;
|
||||||
|
|
||||||
|
-- name: GetAllTgAccounts :many
|
||||||
|
SELECT * FROM tgAccounts WHERE Deleted = false;
|
||||||
|
8
dal/schema/000018_init.down.sql
Normal file
8
dal/schema/000018_init.down.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
DROP TABLE IF EXISTS tgAccounts;
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'tgAccountStatus') THEN
|
||||||
|
DROP TYPE TgAccountStatus;
|
||||||
|
END IF;
|
||||||
|
END $$;
|
16
dal/schema/000018_init.up.sql
Normal file
16
dal/schema/000018_init.up.sql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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 ,
|
||||||
|
Status TgAccountStatus not null,
|
||||||
|
Deleted bool not null default false,
|
||||||
|
CreatedAt timestamp not null default current_timestamp
|
||||||
|
)
|
@ -36,6 +36,8 @@ packages:
|
|||||||
- "./dal/schema/000016_init.down.sql"
|
- "./dal/schema/000016_init.down.sql"
|
||||||
- "./dal/schema/000017_init.up.sql"
|
- "./dal/schema/000017_init.up.sql"
|
||||||
- "./dal/schema/000017_init.down.sql"
|
- "./dal/schema/000017_init.down.sql"
|
||||||
|
- "./dal/schema/000018_init.up.sql"
|
||||||
|
- "./dal/schema/000018_init.down.sql"
|
||||||
engine: "postgresql"
|
engine: "postgresql"
|
||||||
emit_json_tags: true
|
emit_json_tags: true
|
||||||
emit_db_tags: true
|
emit_db_tags: true
|
||||||
|
Loading…
Reference in New Issue
Block a user