     CONSTRAINT t_users_pkey         PRIMARY KEY (c_uid)
 ) INHERITS (t_acl);
 
+create table t_config(
+    c_conf_name TEXT    NOT NULL,
+    c_version   int     NOT NULL DEFAULT 1,
+    c_data      json    NOT NULL
+) INHERITS (t_acl);
 
 CREATE TABLE t_files (
     c_name      TEXT    NOT NULL CHECK(length(c_name) < 4096 ),

COMMENT ON COLUMN t_action.c_title          IS 'column contains name of action';
COMMENT ON COLUMN t_action.c_apply_object   IS 'column specifies whether an action applies to objects or tables. Certain actions, like “create,” apply only to tables. I find the system is easier to manage if I choose my actions so they can only apply to one or the other, not both.';

create table t_status (
    c_name            text   NOT NULL PRIMARY KEY CHECK( length(c_name) >= 3 AND length(c_name) < 100 )
);
COMMENT ON COLUMN t_status.c_name   IS 'column contains name of status for rest of application';

create table t_acl (
    c_uid             serial not null primary key,
    c_owner           int not null default 1,
    c_group           int not null default 1,
    c_unixperms       int not null default unix_to_numeric('764'),
    c_status          text not null references t_status default 'normal'
);

COMMENT ON COLUMN t_acl.c_uid       IS 'unique uid for all objects in database';

  ('test_user2','pass2','salt','test_email2@ww.ww');

  insert into t_action(c_title, c_apply_object) values
        ('stat'         , true),
        ('stat'         , false),
        ('chmod'        , true),
        ('chmod'        , false),
        ('chgrp'        , true),
        ('chgrp'        , false),
        ('chown'        , true),
        ('chown'        , false),
        ('view_acl'     , true),
        ('view_acl'     , false),

        ('read'         , true),
        ('write'        , true),
        ('delete'       , true),
        ('read'         , false),
        ('write'        , false),
        ('login'        , true),
        ('update_passwd', true);

  insert into t_implemented_action
        (c_table        , c_action       , c_status) values
        ('t_users'      , 'login'        , 0 ),
        ('t_users'      , 'update_passwd', 0 ),
        ('t_users'      , 'read'         , 0 ),
        ('t_users'      , 'write'        , 0 ),
        ('t_users'      , 'delete'       , 0 ),
        ('t_files'      , 'read'         , 0 ),
        ('t_files'      , 'write'        , 0 ),
        ('t_files'      , 'delete'       , 0 );

-- c_role = user,owner, owner_group, group, self
-- c_type = object, global
  insert into t_privilege
        (c_role, c_who, c_action       , c_type    , c_related_table, c_related_uid) values
        ('self', 0    , 'update_passwd', 'object'  , 't_users'      , 0),
        ('self', 0    , 'login'        , 'object'  , 't_users'      , 0);

END $$;

