From 249a5cda4a4aaa001be9f37db51c30aef56a1677 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 18 Aug 2022 17:39:12 +0800 Subject: [PATCH] Add bucket, audioFileName, speechMarksFileName, state to speech table --- packages/api/src/entity/speech.ts | 14 ++++++++++++-- .../migrations/0094.do.add_state_to_speech.sql | 17 +++++++++++++++++ .../0094.undo.add_state_to_speech.sql | 17 +++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 packages/db/migrations/0094.do.add_state_to_speech.sql create mode 100755 packages/db/migrations/0094.undo.add_state_to_speech.sql diff --git a/packages/api/src/entity/speech.ts b/packages/api/src/entity/speech.ts index ac64f7e71..d35fac57f 100644 --- a/packages/api/src/entity/speech.ts +++ b/packages/api/src/entity/speech.ts @@ -9,6 +9,13 @@ import { } from 'typeorm' import { User } from './user' +export enum SpeechState { + INITIALIZED = 'INITIALIZED', + COMPLETED = 'COMPLETED', + FAILED = 'FAILED', + CANCELLED = 'CANCELLED', +} + @Entity({ name: 'speech' }) export class Speech { @PrimaryGeneratedColumn('uuid') @@ -22,14 +29,17 @@ export class Speech { elasticPageId!: string @Column('text') - audioUrl!: string + audioFileName!: string @Column('text') - speechMarksUrl!: string + speechMarksFileName!: string @Column('text') voice!: string + @Column('enum', { enum: SpeechState }) + state!: SpeechState + @CreateDateColumn({ default: () => 'CURRENT_TIMESTAMP' }) createdAt!: Date diff --git a/packages/db/migrations/0094.do.add_state_to_speech.sql b/packages/db/migrations/0094.do.add_state_to_speech.sql new file mode 100755 index 000000000..878dbbba7 --- /dev/null +++ b/packages/db/migrations/0094.do.add_state_to_speech.sql @@ -0,0 +1,17 @@ +-- Type: DO +-- Name: add_state_to_speech +-- Description: Add state field to speech table + +BEGIN; + +CREATE TYPE speech_state_type AS ENUM ('INITIALIZED', 'COMPLETED', 'FAILED', 'CANCELLED'); + +ALTER TABLE omnivore.speech + DROP COLUMN audio_url, + DROP COLUMN speech_marks_url, + ADD COLUMN bucket VARCHAR(255) NOT NULL DEFAULT '', + ADD COLUMN audio_file_name VARCHAR(255) NOT NULL DEFAULT '', + ADD COLUMN speech_marks_file_name VARCHAR(255) NOT NULL DEFAULT '', + ADD COLUMN state speech_state_type NOT NULL DEFAULT 'INITIALIZED'; + +COMMIT; diff --git a/packages/db/migrations/0094.undo.add_state_to_speech.sql b/packages/db/migrations/0094.undo.add_state_to_speech.sql new file mode 100755 index 000000000..727277958 --- /dev/null +++ b/packages/db/migrations/0094.undo.add_state_to_speech.sql @@ -0,0 +1,17 @@ +-- Type: UNDO +-- Name: add_state_to_speech +-- Description: Add state field to speech table + +BEGIN; + +DROP TYPE IF EXISTS speech_state_type; + +ALTER TABLE omnivore.speech + DROP COLUMN bucket, + DROP COLUMN audio_file_name, + DROP COLUMN speech_marks_file_name, + DROP COLUMN state speech_state_type, + ADD COLUMN audio_url text NOT NULL, + ADD COLUMN speech_marks_url text NOT NULL; + +COMMIT;