Envers and batch loading scripts - nhibernate-envers

I originally loaded some data through a liquibase script, and this has resulted in the envers audit table missing the insert records. So while I have update records, I do not have original insert records
I've written a data script to reinsert this data with the create records - but it is a fairly heavy weight script as you have to consider 4 scenarios -
Data with existing insert records - no migration
Data with update/delete records but no insert records - need insert records
Data with no audit entries - this is bulk upload without any subsequent changes
Reset Existing records
The scripts written, but is there an easier way to do this? Or did I just mess up not creating the initial insert records?
Im guessing you dont need the update/delete records - but I am using the audit table in a view
Thanks

Do you need to keep old update/delete audit records? If not - and it's ok to "start over" in auditing - you can simply remove all present audit history. Then "move" all present state to audit records as inserts pointing to revision 1 .

Related

Flutter - How to update the table structure in Sqflite?

My app is in production and I want to manage user data when user updates the app without loss of their data, how can I achieve this with sqflite. Explicitly I want to add a column and delete another.
You can probably add a column using raw sql, but sqlite (and thus sqflite) doesn't support dropping a column. For that you would need to do the following:
increase the database version number
in onUpgrade copy the old database columns to a temporary table
delete the original table
create a new table using the original table name but with the right schema
copy the data from the temp table
delete the temp table
Sorry, this isn't a full answer, but it is the direction I would go if I were in your situation.
I have the same problem and found this article which seems to be a good solution.

Records of empty data being returned from Xamarin.iOS SQLite db for one or more tables

I've been facing this problem for the past few days. I am attempting to create a table view that is populated from a database query (seems simple enough). As I will be managing multiple tables, I have created a database helper class to fetch the data by using the sql queries. But it does not work consistently (or at all of late).
When I attempt to query a table, using one of the defined functions, the db return cursors with XX number of records, but null column data. In effect, multiple rows ( I see the row separators), but each row is blank.
Any suggestion or help is highly appreciated.

Insert from stringgrid to MSSQL

I need to copy data from a stringgrid into a MSSQL database table. The table had already been created using a sql statement. We need to copy 4 different table with many fields. Is there any very effective code to grab all data and save them into the database table. If not, I can code a loop sequence and insert the data row by row. But this seems to be very slow and not flexible.

capture/store when fields in database records have been changed/edited

I have a multi user database system which stores records with various fields e.g. text, date time etc.
Does anyone know of a way to capture when fields of a record have been changed/modified by a user. A bit like a audit history which displays all the events which have happened against the record.
I connect to database via tdatasource and TADQuery (fireDAC).
Thanks,
I have seen a solution where every important table has a number of triggers that fire when inserting, updating, deleting records. Those triggers save the old and the new state of the record to a corresponding "history" table.

Append/Insert detail records (NestedDataSet) in DataSetProvider OnUpdateData

I would like to insert detail records in an OnUpdateData event of the DataSetProvider and have the changes updated to the database along with the master record.
What is the best way to achieve this.
I have tried inserting records to the NestedDataSet but they are not sent to the database along with the delta.
Using Delphi 7 or Delphi 2010 with MySQL and dbexpress:
Master: InvoicePayment (SQLDataSet, DataSetProvider, ClientDataSet)
Detail: InvoicePaymentLine (NestedDataSet)
The user inputs payment amounts and the program loops through Delta in an OnUpdateData event processing invoices to be paid and inserts them in the detail table (InvoicePaymentLine) for each master record.
I would prefer not to use BeforeUpdateRecord event but instead process all records at once in a loop.

Resources