Packs proposal
| Version | 1.4 | |
| Created | 2023/06/07 - Michael P. Dubner (https://github.com/pyhedgehog) | |
| Modified | 2024/03/05 - Michael P. Dubner (https://github.com/pyhedgehog) | |
Abstract
This SIP (Saltcorn Improvement Proposal) has goal to make packs more developer-friendly format.
Motivation
Packs pros
Features that should be keept:
- Pack has simple representation that can be constructed manually/programmatically.
 - Pack has text representation that can be stored in VCS.
 - Snapshots are packs.
 - On pack re-import existing triggers are overrided.
 - Pack format is (theoretically) extensible.
 
Packs cons
Defects that should be fixed:
- Packs can be imported only once (#1507)
	
- Existing table cause pack import to fail.
 - Existing view/page silently ignored.
 
 - Packs export can't be easily repeated (#1505)
 - Packs are not self-consistent. There are configuration parts not included:
 - Packs imported from cli (
saltcorn install-pack -f ...) require saltcorn restart. 
Extra ideas
- Plugins or patches for packed application migration. (see #1475-comment)
 
Proposal
- Update existing views, pages (and maybe library items) like triggers.
 - Add ability to define default value for required column in pack.
 - Update existing table definition if posiible fail otherwise.
 - Add "create pack" to tag interface. This will simplify re-export. (done in #2053)
 - Send reload signal from cli install-pack command to server (i.e. SIGHUP which should be handled beforehand).
 
Format changes
- Add format version field (
"format": 1) while absence of this field implies format=0, i.e. old format. - Add version field (
"version": "1.0"by default). - Add custom_events field as list of 
{"name":"...","hasChannel":false}. - Add menu_items field.
 - Add localizer_strings field with translation strings of exported views and pages and menu items.
 - Add data object field with table_name:[rows] fields.
 
Import changes
- Update (aka replace) existing views, pages (and maybe library items) like triggers.
 - Update existing table definition if posiible fail (and rollback) whole pack import otherwise.
 - Apply (add or update) configuration changes (custom_events, menu_items, localizer_strings).
 - Import data using upsert idiom.
 - Process whole import in single transaction to be able to rollback it.
 
Interface changes
- Add ability to define default value for required column in pack (done in #1824 and #2117).
 - Change pack export interface as a whole:
	
- Add pack re-export. Let's add first step with selection "Export new pack" (name it) and "Re-export old pack" (select from installed ones).
 - Add versioning. For new packs versions defaults to 1.0, for re-export we can ever add detection of major changes (fields added).
 - Mark pack installed on export including version bump (update 
installed_packsconfig). - Add "create pack" to tag interface. This will simplify re-export with version increment.
 - Add "dump data" as an option to exported tables excluding readonly (external or provider) tables, tables without PK and tables with high rows count (i.e. >1M).
 
 - Change pack import interface:
	
- Add version to 
installed_packsconfig. - Add checkbox "keep going" to revert to old import behaviour (without transaction).
 
 - Add version to 
 
Misc changes
- Handle reload signal (i.e. SIGHUP). Windows is problem as usual.
 - Send reload signal from cli install-pack command to server (if pid os known).