package Daje::Database::Kanban;
use Mojo::Base -base;
use v5.42;

our $VERSION = '1';

1;

__DATA__

@@ kanban

-- 1 up

-- Autogenerated file, any changes to this file will be over written.
-- Last generated 2026-03-28 17:58:32

    
CREATE TABLE IF NOT EXISTS kanban_list -- 
(
    kanban_list_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
            kanban_planboard_fkey BIGINT  NOT NULL, -- Planboard
                        title  VARCHAR  NOT NULL , -- Title
                        active  BOOLEAN  NOT NULL DEFAULT true , -- Active
                        listid  VARCHAR  NOT NULL DEFAULT '' , -- ListId
                        sort_order  BIGINT  NOT NULL DEFAULT 0 , -- Sort Order
                CONSTRAINT kanban_list_pkey PRIMARY KEY (kanban_list_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_planboard -- 
(
    kanban_planboard_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
            kanban_workflow_fkey BIGINT  NOT NULL, -- Workflow
                        comment  VARCHAR  NOT NULL DEFAULT '' , -- Comment
                        name  VARCHAR  UNIQUE  NOT NULL , -- Planboard name
                    companies_companies_fkey BIGINT  NOT NULL, -- Companies
                    users_users_fkey BIGINT  NOT NULL, -- User
                        active  BOOLEAN  NOT NULL DEFAULT true , -- Active
                        duedate  DATE , -- Due date
                CONSTRAINT kanban_planboard_pkey PRIMARY KEY (kanban_planboard_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_cards -- 
(
    kanban_cards_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                title  VARCHAR  NOT NULL , -- Title
                        description  VARCHAR  NOT NULL DEFAULT '' , -- Description
                        startdate  DATE , -- Start date
                        duedate  DATE , -- Due date
                        completed  BOOLEAN  NOT NULL DEFAULT false , -- Completed
                        progress  BIGINT  NOT NULL DEFAULT 0 , -- Progress
                    kanban_priority_fkey BIGINT  NOT NULL, -- Priority
                    kanban_list_fkey BIGINT  NOT NULL, -- List
                        id  VARCHAR  NOT NULL , -- Card id
                        sort_order  BIGINT  NOT NULL DEFAULT 0 , -- Sort Order
                CONSTRAINT kanban_cards_pkey PRIMARY KEY (kanban_cards_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_assignees -- 
(
    kanban_assignees_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
            kanban_cards_fkey BIGINT  NOT NULL, -- Cards
                    users_users_fkey BIGINT  NOT NULL, -- Users
                        comment  VARCHAR  NOT NULL DEFAULT '' , -- Comment
                        name  VARCHAR  NOT NULL , -- Name
                        image  VARCHAR  NOT NULL DEFAULT '' , -- Image
                CONSTRAINT kanban_assignees_pkey PRIMARY KEY (kanban_assignees_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_comments -- 
(
    kanban_comments_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
            kanban_cards_fkey BIGINT  NOT NULL, -- Cards
                        id  VARCHAR  NOT NULL , -- id
                        text  VARCHAR  NOT NULL , -- Text
                        name  VARCHAR  NOT NULL , -- User commenting
                        image  VARCHAR  NOT NULL DEFAULT '' , -- Avatar
                        comment_date  DATE  NOT NULL DEFAULT now() , -- Comment Date
                CONSTRAINT kanban_comments_pkey PRIMARY KEY (kanban_comments_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_priority -- 
(
    kanban_priority_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                color  VARCHAR  NOT NULL , -- Color
                        title  VARCHAR  NOT NULL , -- Title
                CONSTRAINT kanban_priority_pkey PRIMARY KEY (kanban_priority_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_attachments -- 
(
    kanban_attachments_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
            kanban_cards_fkey BIGINT  NOT NULL, -- Cards
                        filename  VARCHAR  NOT NULL , -- Filename
                        comment  VARCHAR  NOT NULL DEFAULT '' , -- Comment
                        document  BYTEA , -- Document
                        type  VARCHAR  NOT NULL DEFAULT '' , -- Type
                CONSTRAINT kanban_attachments_pkey PRIMARY KEY (kanban_attachments_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_tasks -- 
(
    kanban_tasks_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
            kanban_cards_fkey BIGINT  NOT NULL, -- Cards
                        completed  BOOLEAN  NOT NULL DEFAULT false , -- Completed
                        estimated  NUMERIC (6, 2) NOT NULL DEFAULT 0 , -- Estimated time (h)
                        booked  NUMERIC (6, 2) NOT NULL DEFAULT 0 , -- Booked time (h)
                        id  VARCHAR  NOT NULL , -- id
                        title  VARCHAR  NOT NULL DEFAULT '' , -- title
                CONSTRAINT kanban_tasks_pkey PRIMARY KEY (kanban_tasks_pkey)
);
    
CREATE TABLE IF NOT EXISTS kanban_task -- 
(
    kanban_task_pkey  SERIAL NOT NULL,
    editnum bigint NOT NULL DEFAULT 1,
    insby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    insdatetime timestamp without time zone NOT NULL DEFAULT now(),
    modby character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 'System'::character varying,
    moddatetime timestamp without time zone NOT NULL DEFAULT now(),
                text  VARCHAR  NOT NULL , -- Text
                        completed  BOOLEAN  NOT NULL DEFAULT false , -- completed
                    kanban_tasks_fkey BIGINT  NOT NULL, -- Tasks
                CONSTRAINT kanban_task_pkey PRIMARY KEY (kanban_task_pkey)
);
    

CREATE OR REPLACE VIEW v_kanban_list AS  -- 
    SELECT kanban_list_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_planboard_fkey,
      title,
      active,
      listid,
      sort_order
          FROM kanban_list;
CREATE OR REPLACE VIEW v_kanban_planboard AS  -- 
    SELECT kanban_planboard_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_workflow_fkey,
      comment,
      name,
     companies_companies_fkey,
     users_users_fkey,
      active,
      duedate
          FROM kanban_planboard;
CREATE OR REPLACE VIEW v_kanban_cards AS  -- 
    SELECT kanban_cards_pkey, editnum, insby, insdatetime, modby, moddatetime, title,
      description,
      startdate,
      duedate,
      completed,
      progress,
     kanban_priority_fkey,
     kanban_list_fkey,
      id,
      sort_order
          FROM kanban_cards;
CREATE OR REPLACE VIEW v_kanban_assignees AS  -- 
    SELECT kanban_assignees_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey,
     users_users_fkey,
      comment,
      name,
      image
          FROM kanban_assignees;
CREATE OR REPLACE VIEW v_kanban_comments AS  -- 
    SELECT kanban_comments_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey,
      id,
      text,
      name,
      image,
      comment_date
          FROM kanban_comments;
CREATE OR REPLACE VIEW v_kanban_priority AS  -- 
    SELECT kanban_priority_pkey, editnum, insby, insdatetime, modby, moddatetime, color,
      title
          FROM kanban_priority;
CREATE OR REPLACE VIEW v_kanban_attachments AS  -- 
    SELECT kanban_attachments_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey,
      filename,
      comment,
      document,
      type
          FROM kanban_attachments;
CREATE OR REPLACE VIEW v_kanban_tasks AS  -- 
    SELECT kanban_tasks_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey,
      completed,
      estimated,
      booked,
      id,
      title
          FROM kanban_tasks;
CREATE OR REPLACE VIEW v_kanban_task AS  -- 
    SELECT kanban_task_pkey, editnum, insby, insdatetime, modby, moddatetime, text,
      completed,
     kanban_tasks_fkey
          FROM kanban_task;


CREATE OR REPLACE VIEW v_kanban_list_list AS -- 
    SELECT kanban_list_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_planboard_fkey, title, active, listid, sort_order     FROM kanban_list;

CREATE OR REPLACE VIEW v_kanban_planboard_list AS -- 
    SELECT kanban_planboard_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_workflow_fkey, comment, name,companies_companies_fkey,users_users_fkey, active, duedate     FROM kanban_planboard;

CREATE OR REPLACE VIEW v_kanban_cards_list AS -- 
    SELECT kanban_cards_pkey, editnum, insby, insdatetime, modby, moddatetime, title, description, startdate, duedate, completed, progress,kanban_priority_fkey,kanban_list_fkey, id, sort_order     FROM kanban_cards;

CREATE OR REPLACE VIEW v_kanban_assignees_list AS -- 
    SELECT kanban_assignees_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey,users_users_fkey, comment, name, image     FROM kanban_assignees;

CREATE OR REPLACE VIEW v_kanban_comments_list AS -- 
    SELECT kanban_comments_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey, id, text, name, image, comment_date     FROM kanban_comments;

CREATE OR REPLACE VIEW v_kanban_priority_list AS -- 
    SELECT kanban_priority_pkey, editnum, insby, insdatetime, modby, moddatetime, color, title     FROM kanban_priority;

CREATE OR REPLACE VIEW v_kanban_attachments_list AS -- 
    SELECT kanban_attachments_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey, filename, comment, document, type     FROM kanban_attachments;

CREATE OR REPLACE VIEW v_kanban_tasks_list AS -- 
    SELECT kanban_tasks_pkey, editnum, insby, insdatetime, modby, moddatetime,kanban_cards_fkey, completed, estimated, booked, id, title     FROM kanban_tasks;

CREATE OR REPLACE VIEW v_kanban_task_list AS -- 
    SELECT kanban_task_pkey, editnum, insby, insdatetime, modby, moddatetime, text, completed,kanban_tasks_fkey     FROM kanban_task;




ALTER TABLE kanban_list
    ADD CONSTRAINT kanban_list_kanban_planboard_fkey
        FOREIGN KEY (kanban_planboard_fkey)    REFERENCES kanban_planboard (kanban_planboard_pkey);

CREATE INDEX ind_kanban_list_planboard_fkey
    ON kanban_list(kanban_planboard_fkey);

  
  
  
  
    ALTER TABLE kanban_planboard
    ADD CONSTRAINT kanban_planboard_kanban_workflow_fkey
        FOREIGN KEY (kanban_workflow_fkey)
    REFERENCES workflow (workflow_pkey);
CREATE INDEX ind_kanban_planboard_workflow_fkey
    ON kanban_planboard(kanban_workflow_fkey);

  
  
  ALTER TABLE kanban_planboard
    ADD CONSTRAINT companies_planboard_companies_companies_fkey
        FOREIGN KEY (companies_companies_fkey)    REFERENCES companies_companies (companies_companies_pkey);


CREATE INDEX ind_companies_planboard_companies_fkey
    ON kanban_planboard(companies_companies_fkey);

  
  ALTER TABLE kanban_planboard
    ADD CONSTRAINT users_planboard_users_users_fkey
        FOREIGN KEY (users_users_fkey)    REFERENCES users_users (users_users_pkey);


CREATE INDEX ind_users_planboard_users_fkey
    ON kanban_planboard(users_users_fkey);

  
  
  
    
  
  
  
  
  
  ALTER TABLE kanban_cards
    ADD CONSTRAINT kanban_cards_kanban_priority_fkey
        FOREIGN KEY (kanban_priority_fkey)    REFERENCES kanban_priority (kanban_priority_pkey);

CREATE INDEX ind_kanban_cards_priority_fkey
    ON kanban_cards(kanban_priority_fkey);

  ALTER TABLE kanban_cards
    ADD CONSTRAINT kanban_cards_kanban_list_fkey
        FOREIGN KEY (kanban_list_fkey)    REFERENCES kanban_list (kanban_list_pkey);

CREATE INDEX ind_kanban_cards_list_fkey
    ON kanban_cards(kanban_list_fkey);

  
  
    ALTER TABLE kanban_assignees
    ADD CONSTRAINT kanban_assignees_kanban_cards_fkey
        FOREIGN KEY (kanban_cards_fkey)    REFERENCES kanban_cards (kanban_cards_pkey);

CREATE INDEX ind_kanban_assignees_cards_fkey
    ON kanban_assignees(kanban_cards_fkey);

  ALTER TABLE kanban_assignees
    ADD CONSTRAINT users_assignees_users_users_fkey
        FOREIGN KEY (users_users_fkey)    REFERENCES users_users (users_users_pkey);


CREATE INDEX ind_users_assignees_users_fkey
    ON kanban_assignees(users_users_fkey);

  
  
  
  
    ALTER TABLE kanban_comments
    ADD CONSTRAINT kanban_comments_kanban_cards_fkey
        FOREIGN KEY (kanban_cards_fkey)    REFERENCES kanban_cards (kanban_cards_pkey);

CREATE INDEX ind_kanban_comments_cards_fkey
    ON kanban_comments(kanban_cards_fkey);

  
  
  
  
  
    
  
    ALTER TABLE kanban_attachments
    ADD CONSTRAINT kanban_attachments_kanban_cards_fkey
        FOREIGN KEY (kanban_cards_fkey)    REFERENCES kanban_cards (kanban_cards_pkey);

CREATE INDEX ind_kanban_attachments_cards_fkey
    ON kanban_attachments(kanban_cards_fkey);

  
  
  
  
    ALTER TABLE kanban_tasks
    ADD CONSTRAINT kanban_tasks_kanban_cards_fkey
        FOREIGN KEY (kanban_cards_fkey)    REFERENCES kanban_cards (kanban_cards_pkey);

CREATE INDEX ind_kanban_tasks_cards_fkey
    ON kanban_tasks(kanban_cards_fkey);

  
  
  
  
  
    
  
  ALTER TABLE kanban_task
    ADD CONSTRAINT kanban_task_kanban_tasks_fkey
        FOREIGN KEY (kanban_tasks_fkey)    REFERENCES kanban_tasks (kanban_tasks_pkey);

CREATE INDEX ind_kanban_task_tasks_fkey
    ON kanban_task(kanban_tasks_fkey);

    

CREATE UNIQUE INDEX IF NOT EXISTS idx_unique_kanban_list_listid_kanban_planboard_fkey
      ON kanban_list(listid,kanban_planboard_fkey);



-- Priorities
INSERT INTO kanban_priority (color, title)
VALUES
('#3b82f6','Low'),
('#3b82f6','Medium'),
('#3b82f6','High');





-- 1 down



@@ the_end


