Clean up the schema: drop unused tables, rename scopes, publishable awards
Migrations 020–023, with the code that reads each: - 020 drops people_lists, people_list_members, v_chapters and v_person_affiliations. Nothing queried any of them. - 021 renames event_sections to event_scopes and events.section_id to scope_id, finishing what 015 described. The API sends `scopes` and `scope_id`, and useEvents, EventListCards and EventCalendar take `scope`. It also inserts national/regional/partner, which only the retired seed ever created: a database built from migrations alone had no scope for the Retreats bands. - 022 drops events.sort_order and people.sort_order. Events now sort by date (upcoming soonest first, past latest first, undated last) on /events, org pages and the countdown. People were only ever sorted by sort_name on the site. Every other sort_order stays. - 023 rebuilds teams with created_at and updated_at plus a touch trigger, so the teams editor gets the same optimistic concurrency as the other entities. Awards can be drafted: is_published (added in 011) is on both descriptor halves with a Publishing group, and the award list, award page, org awards and event awards leave drafts out. The migration runner now turns foreign keys off around the per-file transactions and runs foreign_key_check before each commit. PRAGMA foreign_keys is a no-op inside a transaction, so 009's warning was right and a rebuild of a referenced table (023) couldn't be written otherwise. CLAUDE.md is updated to match. Also removes the stray src/App.tsx.save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8790f861fe
commit
25e592bfea
19 changed files with 339 additions and 423 deletions
|
|
@ -27,8 +27,12 @@ const PLACE_FIELDS = [
|
|||
{ path: "is_online", label: "Online", widget: "checkbox" },
|
||||
];
|
||||
|
||||
const PUBLISHED_FIELD = { path: "is_published", label: "Published", widget: "checkbox" };
|
||||
|
||||
/* For entities whose lists the site orders by hand. Events sort by
|
||||
date and people by sort_name, so they take PUBLISHED_FIELD alone. */
|
||||
const PUBLISH_FIELDS = [
|
||||
{ path: "is_published", label: "Published", widget: "checkbox" },
|
||||
PUBLISHED_FIELD,
|
||||
{ path: "sort_order", label: "Sort order", widget: "number" },
|
||||
];
|
||||
|
||||
|
|
@ -392,14 +396,14 @@ const events = {
|
|||
list: {
|
||||
columns: [
|
||||
{ key: "title", label: "Title", primary: true },
|
||||
{ key: "section_id", label: "Scope" },
|
||||
{ key: "scope_id", label: "Scope" },
|
||||
{ key: "event_type", label: "Type" },
|
||||
{ key: "date_label", label: "Dates" },
|
||||
{ key: "status", label: "Status" },
|
||||
{ key: "is_published", label: "Live", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{ key: "section_id", label: "Scope", optionsFrom: "event_sections" },
|
||||
{ key: "scope_id", label: "Scope", optionsFrom: "event_scopes" },
|
||||
{
|
||||
key: "event_type",
|
||||
label: "Type",
|
||||
|
|
@ -414,15 +418,11 @@ const events = {
|
|||
{
|
||||
legend: "Identity",
|
||||
fields: [
|
||||
// The column is still section_id — the rows in event_sections
|
||||
// are what changed, not the schema. Only the label moved,
|
||||
// because "scope" is what the field has always meant and
|
||||
// "section" described where it happened to be rendered.
|
||||
{
|
||||
path: "section_id",
|
||||
path: "scope_id",
|
||||
label: "Scope",
|
||||
widget: "select",
|
||||
optionsFrom: "event_sections",
|
||||
optionsFrom: "event_scopes",
|
||||
required: true,
|
||||
help: "Whose gathering this is. Only national, regional and partner appear on the Retreats page",
|
||||
},
|
||||
|
|
@ -477,7 +477,7 @@ const events = {
|
|||
},
|
||||
timelineGroup("event"),
|
||||
timelineDetailGroup("event"),
|
||||
{ legend: "Publishing", fields: PUBLISH_FIELDS },
|
||||
{ legend: "Publishing", fields: [PUBLISHED_FIELD] },
|
||||
],
|
||||
|
||||
children: [
|
||||
|
|
@ -592,7 +592,7 @@ const people = {
|
|||
{
|
||||
legend: "Publishing",
|
||||
note: "Unpublished people are invisible everywhere, including as chapter leads.",
|
||||
fields: PUBLISH_FIELDS,
|
||||
fields: [PUBLISHED_FIELD],
|
||||
},
|
||||
],
|
||||
|
||||
|
|
@ -757,10 +757,11 @@ const awards = {
|
|||
{ key: "name", label: "Name", primary: true },
|
||||
{ key: "org_id", label: "Awarded by" },
|
||||
{ key: "description", label: "Description" },
|
||||
{ key: "sort_order", label: "Order" },
|
||||
{ key: "is_published", label: "Live", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{ key: "org_id", label: "Awarded by", optionsFrom: "organizations" },
|
||||
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
||||
],
|
||||
},
|
||||
|
||||
|
|
@ -782,9 +783,13 @@ const awards = {
|
|||
{ path: "name", label: "Name", required: true },
|
||||
{ path: "description", label: "Description", widget: "textarea", full: true },
|
||||
{ path: "logo", label: "Logo", help: "Filename in public/org-logos/" },
|
||||
{ path: "sort_order", label: "Sort order", widget: "number" },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Publishing",
|
||||
note: "An unpublished award is a draft: off the site, and a 404 at its own page.",
|
||||
fields: PUBLISH_FIELDS,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
display order — the filter chips read it straight off this array,
|
||||
so moving a line moves a chip.
|
||||
|
||||
What this is not: event_sections. A section owns presentation —
|
||||
What this is not: event_scopes. A scope owns presentation —
|
||||
Retreats.tsx keys its title, accent and background on the id, so
|
||||
an unrecognised section_id makes an event vanish with no error,
|
||||
an unrecognised scope_id makes an event vanish with no error,
|
||||
which is why that one is a real table with a real foreign key. A
|
||||
type carries no presentation of its own and an unknown value
|
||||
renders as its own name, so a CHECK is enough.
|
||||
|
|
|
|||
|
|
@ -79,9 +79,9 @@ export type EventAward = {
|
|||
|
||||
export type EventRecord = {
|
||||
id: string
|
||||
/** Which band of the Retreats page this belongs to. */
|
||||
section_id: string
|
||||
/** What kind of gathering it is. Orthogonal to section_id. */
|
||||
/** Whose gathering it is: an event_scopes id. */
|
||||
scope_id: string
|
||||
/** What kind of gathering it is. Orthogonal to scope_id. */
|
||||
event_type: EventType
|
||||
title: string
|
||||
theme?: string | null
|
||||
|
|
@ -117,10 +117,10 @@ export type EventRecord = {
|
|||
* blocks, people and awards. */
|
||||
export type EventListItem = Omit<EventRecord, 'blocks' | 'people' | 'awards'>
|
||||
|
||||
/** An event_sections row, as GET /events sends it beside the list. */
|
||||
export type EventSection = { id: string; name: string; sort_order: number }
|
||||
/** An event_scopes row, as GET /events sends it beside the list. */
|
||||
export type EventScope = { id: string; name: string; sort_order: number }
|
||||
|
||||
export type EventsResponse = { sections: EventSection[]; events: EventListItem[] }
|
||||
export type EventsResponse = { scopes: EventScope[]; events: EventListItem[] }
|
||||
|
||||
export const useEvent = (id?: string): Resource<EventRecord> =>
|
||||
useRecord<EventRecord>(detailPath('/events', id), 'event')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue