can add a show repeating or non repeating. need a better dialog though with more validation. Also added additional sql files to build directory.
This commit is contained in:
parent
184ee30775
commit
ac27a2f79c
20 changed files with 267 additions and 29 deletions
1
build/sql/defaultdata.sql
Normal file
1
build/sql/defaultdata.sql
Normal file
|
@ -0,0 +1 @@
|
|||
INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'));
|
|
@ -169,6 +169,7 @@ CREATE TABLE "cc_show"
|
|||
"repeats" INT2 NOT NULL,
|
||||
"day" INT2 NOT NULL,
|
||||
"description" VARCHAR(512),
|
||||
"show_id" INTEGER NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
|
@ -331,7 +332,7 @@ DROP TABLE "cc_subjs" CASCADE;
|
|||
|
||||
CREATE TABLE "cc_subjs"
|
||||
(
|
||||
"id" INTEGER NOT NULL,
|
||||
"id" serial NOT NULL,
|
||||
"login" VARCHAR(255) default '' NOT NULL,
|
||||
"pass" VARCHAR(255) default '' NOT NULL,
|
||||
"type" CHAR(1) default 'U' NOT NULL,
|
||||
|
|
7
build/sql/sequences.sql
Normal file
7
build/sql/sequences.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
DROP SEQUENCE schedule_group_id_seq CASCADE;
|
||||
|
||||
CREATE SEQUENCE schedule_group_id_seq;
|
||||
|
||||
DROP SEQUENCE show_group_id_seq CASCADE;
|
||||
|
||||
CREATE SEQUENCE show_group_id_seq;
|
|
@ -1,2 +1,6 @@
|
|||
# Sqlfile -> Database map
|
||||
schema.sql=campcaster
|
||||
sequences.sql=campcaster
|
||||
views.sql=campcaster
|
||||
triggers.sql=campcaster
|
||||
defaultdata.sql=campcaster
|
||||
|
|
23
build/sql/triggers.sql
Normal file
23
build/sql/triggers.sql
Normal file
|
@ -0,0 +1,23 @@
|
|||
----------------------------------------------------------------------------------
|
||||
--calculate_position()
|
||||
----------------------------------------------------------------------------------
|
||||
DROP FUNCTION calculate_position() CASCADE;
|
||||
|
||||
CREATE FUNCTION calculate_position() RETURNS trigger AS
|
||||
'
|
||||
BEGIN
|
||||
IF(TG_OP=''INSERT'') THEN
|
||||
UPDATE cc_playlistcontents SET position = (position + 1)
|
||||
WHERE (playlist_id = new.playlist_id AND position >= new.position AND id != new.id);
|
||||
END IF;
|
||||
IF(TG_OP=''DELETE'') THEN
|
||||
UPDATE cc_playlistcontents SET position = (position - 1)
|
||||
WHERE (playlist_id = old.playlist_id AND position > old.position);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
'
|
||||
LANGUAGE 'plpgsql';
|
||||
|
||||
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents
|
||||
FOR EACH ROW EXECUTE PROCEDURE calculate_position();
|
11
build/sql/views.sql
Normal file
11
build/sql/views.sql
Normal file
|
@ -0,0 +1,11 @@
|
|||
-------------------------------------------------------
|
||||
---cc_playlisttimes
|
||||
-------------------------------------------------------
|
||||
|
||||
CREATE VIEW cc_playlisttimes AS
|
||||
SELECT pl.id, COALESCE(t.length, '00:00:00'::time without time zone) AS length
|
||||
FROM cc_playlist pl
|
||||
LEFT JOIN ( SELECT cc_playlistcontents.playlist_id AS id,
|
||||
sum(cc_playlistcontents.cliplength::interval)::time without time zone AS length
|
||||
FROM cc_playlistcontents
|
||||
GROUP BY cc_playlistcontents.playlist_id) t ON pl.id = t.id;
|
Loading…
Add table
Add a link
Reference in a new issue