drop table if exists articles cascade;
create table articles(
	article_id serial not null,
	article_category_id integer not null references article_categories( article_category_id ),
	article_ctstamp timestamp without time zone default now(),
	article_name varchar(128),
	article_publication_tstamp timestamp without time zone,
	article_depublication_tstamp timestamp without time zone,
	article_ordering_tstamp timestamp without time zone default now(),
	article_rss_publication_tstamp timestamp without time zone,
	article_tech_mtstamp bigint,
	article_url varchar(255),
	article_leadpicture varchar(255),
	is_url_used boolean default false,
	is_active boolean default true,
	is_public boolean default true,
	is_deleted boolean default false,
	is_memberonly boolean default false,
	is_subscriberonly boolean default false,
	oldid integer,
	constraint articles_pkey primary key( article_id )
);

comment on table articles is 'storage of articles';
comment on column articles.article_id is 'unique id of table';
comment on column articles.article_category_id is 'reference id to article_categories table';
comment on column articles.article_ctstamp is 'creation timestamp of article';
comment on column articles.article_name is 'name of the article';
comment on column articles.article_publication_tstamp is 'publication timestamp of article';
comment on column articles.article_depublication_tstamp is 'depublication timestamp of article';
comment on column articles.article_ordering_tstamp is 'ordering timestamp of article';
comment on column articles.article_rss_publication_tstamp is 'publication timestamp of article in rss';
comment on column articles.article_tech_mtstamp is 'technical last modification timestamp (epoch)';

comment on column articles.article_url is 'url of the article';
comment on column articles.article_leadpicture is 'leadpicture of the article';
comment on column articles.is_url_used is 'is article url used on fallback';
comment on column articles.is_active is 'is active flag of article';
comment on column articles.is_public is 'is public flag of article';
comment on column articles.is_deleted is 'is deleted flag of article';
comment on column articles.is_memberonly is 'is article viewable by members only flag';
comment on column articles.is_subscriberonly is 'is article viewable by active subscribers only flag';
comment on column articles.oldid is 'old id from fordit v2';

comment on constraint articles_pkey on articles is 'unique constraint of table';
comment on constraint articles_article_category_id_fkey on articles is 'foreign constraint to article_categories table';
