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

our $VERSION = '1';

1;

__DATA__

@@ companies

-- 1 up

-- Autogenerated file, any changes to this file will be over written.
-- Last generated 2026-03-15 11:17:37

    
CREATE TABLE IF NOT EXISTS companies_users -- 
(
    companies_users_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(),
                comment  VARCHAR  NOT NULL DEFAULT '' , -- Comment
                    companies_companies_fkey BIGINT  NOT NULL, -- 
                    users_users_fkey BIGINT  NOT NULL, -- 
                CONSTRAINT companies_users_pkey PRIMARY KEY (companies_users_pkey)
);
    
CREATE TABLE IF NOT EXISTS companies_companies -- 
(
    companies_companies_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(),
                registrationnumber  VARCHAR  NOT NULL DEFAULT '' , -- Registration number
                        homepage  VARCHAR  NOT NULL DEFAULT '' , -- Company homepage
                        active  BOOLEAN  NOT NULL DEFAULT true , -- Is the company active ?
                        boards_office  VARCHAR  NOT NULL DEFAULT '' , -- Boards office official address
                    companies_workflow_fkey BIGINT  NOT NULL, -- 
                        name  VARCHAR  NOT NULL DEFAULT '' , -- Company name
                CONSTRAINT companies_companies_pkey PRIMARY KEY (companies_companies_pkey)
);
    

CREATE OR REPLACE VIEW v_companies_users AS  -- 
    SELECT companies_users_pkey, editnum, insby, insdatetime, modby, moddatetime, comment,
     companies_companies_fkey,
     users_users_fkey
          FROM companies_users;
CREATE OR REPLACE VIEW v_companies_companies AS  -- 
    SELECT companies_companies_pkey, editnum, insby, insdatetime, modby, moddatetime, registrationnumber,
      homepage,
      active,
      boards_office,
     companies_workflow_fkey,
      name
          FROM companies_companies;


CREATE OR REPLACE VIEW v_companies_users_list AS -- 
    SELECT companies_users_pkey, editnum, insby, insdatetime, modby, moddatetime, comment,companies_companies_fkey,users_users_fkey     FROM companies_users;

CREATE OR REPLACE VIEW v_companies_companies_list AS -- 
    SELECT companies_companies_pkey, editnum, insby, insdatetime, modby, moddatetime, registrationnumber, homepage, active, boards_office,companies_workflow_fkey, name     FROM companies_companies;





  ALTER TABLE companies_users
    ADD CONSTRAINT companies_users_companies_companies_fkey
        FOREIGN KEY (companies_companies_fkey)    REFERENCES companies_companies (companies_companies_pkey);

CREATE INDEX ind_companies_users_companies_fkey
    ON companies_users(companies_companies_fkey);

  ALTER TABLE companies_users
    ADD CONSTRAINT users_users_users_users_fkey
        FOREIGN KEY (users_users_fkey)    REFERENCES users_users (users_users_pkey);


CREATE INDEX ind_users_users_users_fkey
    ON companies_users(users_users_fkey);

  
    
  
  
  
  ALTER TABLE companies_companies
    ADD CONSTRAINT companies_companies_companies_workflow_fkey
        FOREIGN KEY (companies_workflow_fkey)
    REFERENCES workflow (workflow_pkey);
CREATE INDEX ind_companies_companies_workflow_fkey
    ON companies_companies(companies_workflow_fkey);

  
    







-- 1 down



@@ the_end


