drop table if exists article_categories cascade;
create table article_categories(
	article_category_id serial not null,
	article_category_parentid integer references article_categories( article_category_id ),
	article_category_level integer default 1,
	article_category_ordering integer,
	article_category_name varchar(128),
	is_public boolean default true,
	is_active boolean default true,
	is_deleted boolean default false,
	article_category_meta_l integer,
	article_category_meta_r integer,
	constraint article_categories_pkey primary key( article_category_id )

);

comment on table article_categories is 'storage of article categories';
comment on column article_categories.article_category_id is 'unique id of table';
comment on column article_categories.article_category_parentid is 'parental id of article category';
comment on column article_categories.article_category_level is 'cache field of level (1 if parentid is null)';
comment on column article_categories.article_category_ordering is 'ordering on the level';
comment on column article_categories.article_category_name is 'name of the category';
comment on column article_categories.is_public is 'public flag of the category';
comment on column article_categories.is_active is 'active flag of the category';
comment on column article_categories.is_deleted is 'deleted flag of the category';
comment on column article_categories.article_category_meta_l is 'nested tree metadata - left';
comment on column article_categories.article_category_meta_r is 'nested tree metadata - right';

comment on constraint article_categories_pkey on article_categories is 'unique constraint of table';
comment on constraint article_categories_article_category_parentid_fkey on article_categories is 'parental constraint';
