Spaces:
Runtime error

File size: 1,294 Bytes
a0e8676
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
create table if not exists campus_documents (
  id bigserial primary key,
  source_name text not null default '绵阳城市学院教务处',
  source_type text not null default 'official_website',
  category text,
  title text not null,
  department text not null default '教务处',
  publish_date date,
  source_url text not null unique,
  content text,
  content_hash text not null,
  attachments jsonb not null default '[]'::jsonb,
  status text not null default 'active',
  last_checked_at timestamptz not null default now(),
  created_at timestamptz not null default now(),
  updated_at timestamptz not null default now()
);

create index if not exists idx_campus_documents_publish_date
  on campus_documents (publish_date desc);

create index if not exists idx_campus_documents_category
  on campus_documents (category);

create index if not exists idx_campus_documents_search
  on campus_documents using gin (
    to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(content, ''))
  );

create table if not exists sync_runs (
  id bigserial primary key,
  started_at timestamptz not null default now(),
  finished_at timestamptz,
  status text not null default 'running',
  scanned_count integer not null default 0,
  upserted_count integer not null default 0,
  error text
);