A single setting to disable all schema changes (DDL) at run time, Lookup contents included

Offen
#1,649 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 6 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
15/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
mysql, postgresql, python
Bereich
backend, databases

Rechercherichtung

Start with schemas.py around lines 329-340 (Lookup contents insertion) and Schema.call / _decorate_table, then autopopulate.py lines 186-187 and jobs.py lines 383-384, where jobs tables are declared. The open design question is where a single allow_ddl check should sit, and whether it must cover alter() and drop(). Done means that with the setting false, each of these paths raises a clear error naming the setting, and an explicit declare_all() path exists for deployments.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What the library does today

Schema changes happen implicitly whenever a process activates a schema with a privileged login:

  • Activating a schema declares every table that doesn't exist yet (Schema.__call__ → _decorate_table, when create_tables is true, the default).
  • Declaring a Lookup table inserts any contents rows that are missing (schemas.py:329–340).
  • populate() and jobs.refresh() declare a table's ~~jobs table on first use (autopopulate.py:186–187, jobs.py:383–384), even when create_tables is false.
  • alter() and drop() run whenever they're called.

So setting create_tables=False, as the production guide advises, still leaves schema changes at run time, through the jobs tables and Lookup contents. Nothing turns them all off at once.

Proposal

A single setting, for example database.allow_ddl (env DJ_ALLOW_DDL), default true. With it set to false, nothing changes the schema:

  • no table, part or jobs-table declaration;
  • no Lookup contents inserted, updated or deleted;
  • no alter(), drop() or schema creation.

An attempt raises a clear error naming the setting, rather than silently doing nothing. A missing table is reported as missing, not declared, and populate() and refresh() fail clearly if a jobs table doesn't exist.

Why

In a controlled deployment, schema changes are a deployment step: planned, reviewed and applied together, before the new code runs. Run-time processes (workers, notebooks, dashboards) then read and write rows but never change the schema. This setting lets an operator enforce that in the library, not only through database privileges.

Also needed

An explicit way for the deployment step to apply schema changes (declare missing tables, their jobs tables and Lookup contents) with the setting on, e.g. a schema.declare_all(), or the setting being overridable for one call.

Expected behavior

With allow_ddl=false, a pipeline whose tables all exist runs as before; one with a missing table, a missing jobs table or changed Lookup contents fails at activation or populate, with a message that says what's missing.

Related

#1552 proposes declaring draft tables on the server beside the pipeline's tables. With schema changes treated as a deployment step, should drafting stay entirely in memory instead?

Vorherrschende Sprache
Python
Sterne
198
Forks
103
Ø Merge
6 T. 1 Std.
Gemergte PRs (30 T.)
10

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus datajoint/datajoint-python

Alle Issues in datajoint/datajoint-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.