Skip to content

Local dev environment for steakweb#2

Open
sparkyfen wants to merge 4 commits into
Shadytel:mainfrom
sparkyfen:dev-environment
Open

Local dev environment for steakweb#2
sparkyfen wants to merge 4 commits into
Shadytel:mainfrom
sparkyfen:dev-environment

Conversation

@sparkyfen

Copy link
Copy Markdown
Contributor

Runs steakweb locally against a throwaway Postgres, with no prod DB or real SAML IdP. I used it to test the activation and directory changes.

Builds on #1 — its test checklist assumes those fixes are in, so merge #1 first. Until it lands, this PR also lists #1's commits; they drop off once #1 is merged, leaving just the dev-env commit.

Everything's under dev/:

  • docker-compose.yml — Postgres on 127.0.0.1:5433, loads the schema and seed on first boot.
  • schema.sql — reconstructed registered_extensions, since there's no schema in the repo. publish/provisioned are char(1) holding 't'/'f', because that's what the code binds — a real bool column would make asyncpg reject the string.
  • seed.sql — a handful of rows to test against: published and unpublished, a name with HTML in it, an out-of-range number, and one that triggers the "already taken" path.
  • config.dev.json — points at the local DB. config.json stays gitignored.
  • README.md — setup and what to click.

The only thing touched outside dev/ is a STEAKWEB_DEV-gated block in steakweb.py: a /dev/login that fakes a session, a TCP bind, and skipping the SAML metadata fetch. It's all behind os.environ.get('STEAKWEB_DEV'), so prod is unchanged.

The schema's a guess from reading the code, not the real one — swap it in if you have it.

@supersat

supersat commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Can you rebase on what is in main now?

I can also provide a definitive schema:

CREATE TYPE public.switch_address_type AS ENUM (
    'AAR',
    'ENP',
    'sipv4',
    'sipv6',
    'other'
);

CREATE TYPE public.switch_type AS ENUM (
    'tdm',
    'isr',
    'sip'
);

CREATE TABLE public.registered_extensions (
    extn integer NOT NULL,
    name text,
    userid integer,
    switch integer,
    port text,
    auth_code text,
    reservation_time timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    last_updated timestamp without time zone,
    expires_at timestamp without time zone,
    publish boolean DEFAULT true NOT NULL,
    provisioned boolean DEFAULT true NOT NULL
);

CREATE TABLE public.switches (
    id integer NOT NULL,
    type public.switch_type NOT NULL,
    address text,
    address_type public.switch_address_type NOT NULL,
    name text,
    description text,
    sip_gateway text
);

CREATE SEQUENCE public.switches_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER TABLE ONLY public.switches ALTER COLUMN id SET DEFAULT nextval('public.switches_id_seq'::regclass);

sparkyfen added a commit to sparkyfen/steakweb that referenced this pull request Jul 3, 2026
Replaces the schema reconstructed from steakweb.py's queries with the
definitive one posted in PR Shadytel#2 (boolean publish/provisioned, the extra
extension columns, and the switches table), and reseeds to match. Adds a
primary key on extn, which the posted schema omits but create_extn's
"already taken" handling depends on.
@sparkyfen

Copy link
Copy Markdown
Contributor Author

Can you rebase on what is in main now?

I can also provide a definitive schema:

CREATE TYPE public.switch_address_type AS ENUM (
    'AAR',
    'ENP',
    'sipv4',
    'sipv6',
    'other'
);

CREATE TYPE public.switch_type AS ENUM (
    'tdm',
    'isr',
    'sip'
);

CREATE TABLE public.registered_extensions (
    extn integer NOT NULL,
    name text,
    userid integer,
    switch integer,
    port text,
    auth_code text,
    reservation_time timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    last_updated timestamp without time zone,
    expires_at timestamp without time zone,
    publish boolean DEFAULT true NOT NULL,
    provisioned boolean DEFAULT true NOT NULL
);

CREATE TABLE public.switches (
    id integer NOT NULL,
    type public.switch_type NOT NULL,
    address text,
    address_type public.switch_address_type NOT NULL,
    name text,
    description text,
    sip_gateway text
);

CREATE SEQUENCE public.switches_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER TABLE ONLY public.switches ALTER COLUMN id SET DEFAULT nextval('public.switches_id_seq'::regclass);

Rebased on main and swapped your schema in, thanks. I kept one addition in the dev copy: a primary key on extn, since create_extn detects "already taken" by catching the unique violation. If prod doesn't have one either, duplicates insert silently, probably worth checking.

The real schema also caught a bug: publish is boolean but create_extn binds the string 't'/'f', which asyncpg won't accept, so creating an extension 500s. Fixed in #3, together with two mis-indented lines that snuck into the #1 merge (main doesn't parse right now, so #3 should land before anything deploys) and an unpublish fix. This branch sits on top of #3; the extra commits drop off once it merges.

Re-ran the checklist against the new schema and it all works.

sparkyfen added 4 commits July 9, 2026 23:15
The publish column is boolean (per the schema supersat posted in Shadytel#2), and
asyncpg rejects a str parameter for a boolean column, so inserting the
string 't'/'f' fails with a DataError. Pass a real bool instead.
The homepage row form posts the checkbox as 'published', but the
non-admin path read 'publish' with a default of '1', so a regular user
could never unpublish a line. Use the same key and default as the admin
path.
Run steakweb against a throwaway Postgres with no SAML IdP, to test the
activation and directory changes locally. dev/ has the docker-compose, a
reconstructed schema (none exists in the repo), seed data, a local config,
and a README. steakweb.py gets a STEAKWEB_DEV-gated dev login and TCP bind
that do nothing in prod. Adds a .gitignore.
Replaces the schema reconstructed from steakweb.py's queries with the
definitive one posted in PR Shadytel#2 (boolean publish/provisioned, the extra
extension columns, and the switches table), and reseeds to match. Adds a
primary key on extn, which the posted schema omits but create_extn's
"already taken" handling depends on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants