Fix program sequences db view
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
10f1003b56
commit
7efb3b81bd
@ -0,0 +1,8 @@
|
|||||||
|
DROP VIEW program_sequences;
|
||||||
|
|
||||||
|
CREATE VIEW program_sequences AS
|
||||||
|
SELECT psi.program_id program_id,
|
||||||
|
json_group_array(json_object(
|
||||||
|
'section_id', psi.section_id,
|
||||||
|
'duration', psi.duration)) sequence
|
||||||
|
FROM program_sequence_items as psi;
|
15
src/database/migrations/0006-fix_view_program_seq-up.sql
Normal file
15
src/database/migrations/0006-fix_view_program_seq-up.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
DROP VIEW program_sequences;
|
||||||
|
|
||||||
|
CREATE VIEW program_sequences AS
|
||||||
|
WITH psi_sorted AS (
|
||||||
|
SELECT psi.program_id program_id,
|
||||||
|
json_object(
|
||||||
|
'section_id', psi.section_id,
|
||||||
|
'duration', psi.duration)
|
||||||
|
obj
|
||||||
|
FROM program_sequence_items AS psi
|
||||||
|
ORDER BY psi.program_id, psi.seq_num)
|
||||||
|
SELECT psi_sorted.program_id program_id,
|
||||||
|
json_group_array(json(psi_sorted.obj)) sequence
|
||||||
|
FROM psi_sorted
|
||||||
|
GROUP BY psi_sorted.program_id;
|
@ -17,6 +17,7 @@ pub fn create_migrations() -> Migrations {
|
|||||||
migs.add(include_file_migration!(3, "0003-table_programs"));
|
migs.add(include_file_migration!(3, "0003-table_programs"));
|
||||||
migs.add(include_file_migration!(4, "0004-program_rows"));
|
migs.add(include_file_migration!(4, "0004-program_rows"));
|
||||||
migs.add(include_file_migration!(5, "0005-view_program_sequence"));
|
migs.add(include_file_migration!(5, "0005-view_program_sequence"));
|
||||||
|
migs.add(include_file_migration!(6, "0006-fix_view_program_seq"));
|
||||||
// INSERT MIGRATION ABOVE -- DO NOT EDIT THIS COMMENT
|
// INSERT MIGRATION ABOVE -- DO NOT EDIT THIS COMMENT
|
||||||
migs
|
migs
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user