UserAuthRole created even if UseDistinctRoleTables is false - servicestack

When not using separate table for Role, e.g. UseDistinctRoleTables=false why is UserAuthRole table still created? I checked the source code, which has if-clauses for UseDistinctRoleTables many places, but not in InitSchema().
It is confusing to have empty tables that are not in use. Is there a purpose, or could this be changed?

Yeah it's not necessary for it to be generated which has been resolved from this commit.
This change is available from the latest v5.11.1 that's now available on MyGet.

Related

Inbound Persistence Hooks = >PrePersistHook: Getting old instance

The PrePersistHook offers this method
Optional<ItemModel> execute(ItemModel item);
When implementing the PrePersistHook the changed model is passed to the method. The executing path already open a transaction and it seems that the item is already persisted, but the transaction is not committed, yet.
If I try to get the same Item again from the database with flexible search, it returns the already updated object.
The documentation => https://help.sap.com/viewer/bad9b0b66bac476f8a4a5c4a08e4ab6b/v2005/en-US/028a2af06880407cb4b1c0624693dadd.html
defines that one should not open transactions or create new threads.
But if it is not allowed, how is it possible to get the old version of the Model in a PrePersistHook to perform a validation or perform other check before the changes are persisted?
In our case, we want to create a new version of the OrderModel, but the persisted old version ever already have the old values. We see no opportunity to get the old version in a clean way.
Many standard prepersist hooks always fetch the item again from the database and return Option.empty() in the hook
Best Regards,
Michael.
I found a solution that works for me. I override the DefaultModelEntityService and read the data before it's updated.

How to create tables in Hybris without init?

Some time ago two new types were created without deployment tables and their items were stored in ComposedType's table. After a while, this problem was noticed and deployment tables were added to *-items.xml but these two tables aren't created during update. How can I handle this problem? Unfortunately, I can't use init on our environments.
You need to define two new itemtypes with the desired deployment table in the items.xml and perform system update. Then, you need to import the data from the two old itemtypes to the new itemtypes. Finally, you need to delete the old columns using SQL command and clear the orphaned types from hAC.

add extra fields to a brightway activity from an existing database

I want to store information in some activities that are modified versions of activities imported from an existing database (ecoinvent).
I know we can add fields to activities created from scratch (example). (I guess this is because the structure of the database has not yet been defined...) but is there a way of adding it to activities of an already defined database without breaking it?
The way around I found is to add entries to the author dict, which I can easily access later on. e.g.
act['author']['scenario']='myscenario'
but I admit it is not a very elegant solution.
You can just add whatever data you want. Brightway is a (semi-)schemaless database for exactly this reason.
act['foo'] = 'bar'
act.save()

Unmanaged installation and Entities data

I have unmanaged solution installed in un online prod environnement and I want to install a new version of this solution in the same environnement, my question is that if I do that, what will happen to my data entities as I don't want to lose my data from the environnement?
Thanks in advance,
The data in the base tables will be not be altered when importing a new solution.
It will be the entity definition.
If a new attribute has been created for an entity which is set to Business Required then a null value will be held until a user opens the form which will require that value to be supplied before the record can be updated.
+1 to Stefan's answer. I will also add that unmanaged solutions will never delete any data. It is always additive, so if you remove an attribute from an entity in your solution in dev, it will not be removed when you import it into another environment. You'll need to manually track these removals and remove them post solution deployment.

PouchDB - Manually managing conflicts

Is it possible to manage the sync conflicts from the client?
What I mean is, when pouchDB does a sync and detects a conflict, is it possible to get the local doc PouchDB is trying to sync and the last revision of CouchDB doc? If I can get both docs, I can display them to the user and he can choose which version to keep...
You're in luck, because this is exactly the problem CouchDB and PouchDB were designed to solve.
Basically you can read up on the CouchDB docs on conflict resolution. Everything in there should also apply to PouchDB. (If it doesn't, it's a bug. ;)). The CouchDB wiki also has a nice writeup.
Edit: so to provide more details, you'll want to fetch the document with ?conflicts=true ({conflicts:true} in PouchDB). E.g. you'll fetch a doc like this:
http://localhost:5984/db1/foo?conflicts=true
And get a doc back like this:
{
"_id":"foo",
"_rev":"2-f3d4c66dcd7596419c76b2498b3ba21f",
"notgonnawork":"this is from the second db",
"_conflicts":["2-c1592ce7b31cc26e91d2f2029c57e621"]
}
Here I have a conflict introduced from another database, and that database's revision has won (randomly). This document's current revision starts with 2-, and the conflicting version also starts with 2-, indicating that they're both at the same level of the revision tree.
To get the conflicting version, you just grab the conflicting rev and call:
http://localhost:5984/db1/foo?rev=2-c1592ce7b31cc26e91d2f2029c57e621
And you get:
{
"_id":"foo",
"_rev":"2-c1592ce7b31cc26e91d2f2029c57e621",
"notgonnawork":"this is from the first database"
}
So after presenting the two conflicting versions to the user, you can then add a 3rd revision on top of both of these, which either combines the results, or chooses the losing version, or whatever you want. This next revision will be prefixed with 3-. Make sense?
Edit: Apparently you also need to delete the conflicting version, or else it will still show up in _conflicts. See this answer.

Resources