create 23 migarate for update colum sex in table gigachatAudience
This commit is contained in:
parent
be6361f19f
commit
24e1055d0c
0
dal/schema/000023_init.down.sql
Normal file
0
dal/schema/000023_init.down.sql
Normal file
14
dal/schema/000023_init.up.sql
Normal file
14
dal/schema/000023_init.up.sql
Normal file
@ -0,0 +1,14 @@
|
||||
BEGIN;
|
||||
ALTER TABLE gigachatAudience RENAME COLUMN Sex TO Sex_old;
|
||||
ALTER TABLE gigachatAudience ADD COLUMN Sex INTEGER;
|
||||
UPDATE gigachatAudience
|
||||
SET Sex = CASE
|
||||
WHEN Sex_old = FALSE THEN 0
|
||||
WHEN Sex_old = TRUE THEN 1
|
||||
ELSE 2
|
||||
END;
|
||||
ALTER TABLE gigachatAudience DROP COLUMN Sex_old;
|
||||
ALTER TABLE gigachatAudience ALTER COLUMN Sex SET NOT NULL;
|
||||
ALTER TABLE gigachatAudience
|
||||
ADD CONSTRAINT check_sex_valid_values CHECK (Sex IN (0, 1, 2));
|
||||
COMMIT;
|
@ -42,7 +42,7 @@ var EmptyResponseErrorGigaChat = errors.New("empty response from GigaChat try ag
|
||||
type GigaChatAudience struct {
|
||||
ID int64 `json:"id"`
|
||||
QuizID int64 `json:"quiz_id"`
|
||||
Sex bool `json:"sex"` // false - female, true - male
|
||||
Sex int `json:"sex"` // 0 - female, 1 - male, 2 - not sex
|
||||
Age string `json:"age"`
|
||||
Deleted bool `json:"deleted"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
|
@ -46,6 +46,8 @@ packages:
|
||||
- "./dal/schema/000021_init.down.sql"
|
||||
- "./dal/schema/000022_init.up.sql"
|
||||
- "./dal/schema/000022_init.down.sql"
|
||||
- "./dal/schema/000023_init.up.sql"
|
||||
- "./dal/schema/000023_init.down.sql"
|
||||
engine: "postgresql"
|
||||
emit_json_tags: true
|
||||
emit_db_tags: true
|
||||
|
Loading…
Reference in New Issue
Block a user