Control Version System - update children when updating their parent? - version-control

I have big problem with my control version system.
In DB I have 2 tables: FolderChanges and FileChanges. The new record is inserted when I commit a change.
For example:
File1 has id=1 and orginalid=1 (points to the first version of file)
I change it and insert File2 id=2 orginalid=1.
But the problem is with folders. Files and folders have a FolderId (which points to their parents).
So if I change a folder I have to change its child.
So my question is this:
Should I insert a new record in the FileChanges table with the same data and only FolderId changed or should I add a column in FileChanges (for example: ChangeDate) and when parents are updated (new file in FolderChanges) change the FolderId pointer to the newest version of the parent and modify ChangeDate?
I hope I explained that well enough.
Thanks!

Related

How to delete one record using frappe.db.delete syntax?

I’m looking to use frappe.db.delete to remove the most recently modified record in a custom table, Warehouse Locations. I want to limit the delete to only one record that matches some filters.
The table is a child table, if that matters.
I am not clear on how to filter one record, based on the “modified” value. I tried:
frappe.db.delete(‘Warehouse Locations’,
{“warehouse”: warehouse,
“parent”: item_code,
“shelf”: shelf,
“modified”:("=",last_record_to_keep[0].modified)})
I am getting a syntax error when I run the above query.
First, filter out the record to be deleted using ORM by running
record = frappe.get_list('Warehouse Locations', order_by='-modified')[0]
Once you filtered it out, you can delete it using frappe.db.delete.
frappe.db.delete('Warehouse Locations', record)
I think the solution answered by #ChillarAnand is helpful.
Instead, I would like to give a different way to solve the problem you faced.
Per your question, the goal is to delete only one record from Warehouse Locations (Child Table).
# 1. Get the parent document for the warehouse location.
parent_doc = frappe.get_doc("Doctype", docname)
# 2. iterate through the child table rows to find the row meet your filter
# and assign to row_to_detele for late use or you can delete straight away
row_to_delete = ""
for row in parent_doc.warehouse_locations:
if row.modified == last_record_to_keep[0].modified:
row_to_delete = row.name
break
# 3. to remove the child table from the parent doc method
parent_doc.remove(row_to_delete)
For the document of parent_doc.remove(), you can find it through the below github path: https://github.com/frappe/frappe/blob/6b91ade73c07dc1c070ed137cf54a29a3e7b0993/frappe/model/base_document.py#L210 (7 Oct, 2021)

SSTable folder naming convention

I just noticed that my newly created sstable folder has a combination of numbers and letters attached. For my table "tweets" it looks like:
/var/lib/cassandra/data/twitter/tweets-a6da23906d8211e8a057ffb9a095df5c
on the disk. Does anybody know what this attached hash is?
Thanks!
Christian
The folder name consists of table name, and table ID that is generated anew every time when the table is created - this is done to prevent race condition when table created, dropped, created, etc.

TYPO3: How to check if a record is new or just a copy

I implemented two hooks (processDatamap_afterDatabaseOperations and processDatamap_postProcessFieldArray) to manipulate any record after saving.
My Question is:
Every time I copy or create a record I enter the hooks and get a parameter "status" which is always "new" no matter if the record is actually new or just a copy of an existing record.
It seems like TYPO3 handles copies as new records.
How can I check if a record is actually a copy or a new record?
I am currently working with TYPO3 Version 8.7.9.
You can use the t3_origuid.
It should be added to your extbase domain model.
See here.
After handling the "copy" command the id of the original record will be copied into this field.
So in the hooks:
processDatamap_preProcessFieldArray or processDatamap_postProcessFieldArray you can access to it.
Like:
if(isset($fieldArray['t3_origuid']) {
<your_code>
}

missing data for column xxx

I've downloaded multiple metro extracts from openstreetmap as PBF files when i try to import them with osm2pgsql it works for the first and creates the tables. I then want to add a column in the planet_osm_ways with a cityID to know which "way id" belonged to which city after i then try to import another city it says 'ERROR: Missing data for column "city_id". is there a way to modify the planet_osm_ways table without breaking the script? I really need to know which id belonged to which metro extract.
You need to edit the style file (default.style, possibly in osm2pgsql-bin directory) used by osm2pgsql.
You can then add the instruction
#Add custom column
node,way citiid int4 linear
The column will be created, and - provided no tag has this name - will not be populated. You are then free to populate it as you want.

Filemaker Pro 14 History tables

With a few solutions Ive worked with I've created temp table's or history tables. Normally I script it to take a handful of fields needed from a main table and copy it over to the other table by
Setting a variable then setting field to the variable for each field in the new table / new record.
I have a situation now, where Im building a history table that needs to copy the current record as is. A snapshot where all fields from that instance of the record are copied to the history table.
Rather then setting a variable then set field to the variable, Id like to get some input on a quicker way to get this done where I can do this on a record level and not type out field by field to get it done. Also if fields are added to both tables then I have to make sure my script gets updated.
Ill keep hunting around.. appreciate any help.
-Rich
Do you have a sample of copying a record from 1 table to another
including all fields and setting some fields?
As I suggested in comments, use the Import Records[] script step, and select the same file as the source. If you choose Arrange by: [ matching names ] in the Import Field Mapping dialog, it will automatically map all source fields to their similarly named counterparts.
Note that you must establish a found set in the source table before importing.
For "setting some fields", you can define auto-enter options and activate them during the import, or run Replace Field Contents[] immediately after the import.