# Epic: version control # Current [Reports Table](https://github.com/NASA-IMPACT/snwg-backend/blob/develop/app/db/models.py#L22-L41) [ReportVersions Table](https://github.com/NASA-IMPACT/snwg-backend/blob/develop/app/db/models.py#L54-L98) ```jsx= Reports: id: Int(primary_key, index, autoincrement) title: String alias: String(unique) created_by: String created_at: DateTime last_updated_by: String last_updated_at: DateTime versions: relationship(ReportVersions) ReportVersions: report_id: Int(primary_key, index) major: Int(primary_key) // this is static right now in SNWG minor: Int // this is static right now in SNWG // Never updated created_by: String created_at: DateTime // Snapshot not required fields // -- Normal fields owner: String authors: [String] reviewers: [JSON] locked_by: String published_by: String published_at: DateTime threads: [threads] // -- Auto generated values fields searchable: TSVECTOR last_updated_by: String last_updated_at: DateTime status: String // *** Fields to save for version control *** journal_status: String keywords: [JSON] doi: String document: JSON citation: JSON publication_checklist: JSON sections_completed: JSON ``` # New ## Back-end ### Add New table `ReportVersionSnapshots` ```jsx= ReportVersionSnapshots: id: Int(primary, index) // Report version id report_id: Int(index) major: Int // Metadata created_by: String created_at: DateTime changelog: String(Text) // Snapshot data journal_status: String keywords: [JSON] doi: String document: JSON citation: JSON publication_checklist: JSON sections_completed: JSON ``` ### Add new endpoints - GET `/reports/{report_id}/versions/{version}/snapshots` - Permission check (same as GET `/reports`) - List `ReportVersionSnapshots` Summary ```jsx= ReportVersionSnapshotSummaryOutput: id: Int created_by: String created_at: DateTime changelog: String(Text) ``` - GET `/reports/{report_id}/versions/{version}/snapshots/{snapshot_id}` - Permission check (same as GET `/reports`) - Retrieve `ReportVersionSnapshots` Detail ### Modify endpoints - POST `/reports` - Create `ReportVersionSnapshots` using latest `ReportVersions` - POST `/reports/{report_id}` - Create `ReportVersionSnapshots` using latest `ReportVersions` ## Front-end - List snapshots by ReportVersion - Retrieve snapshot - Fill edit form for ReportVersion using snapshot - User can modify if needed - User can save ReportVersion - Generate new snapshot