How to remove a single relationship? - suitecrm

I have created a custom module and added some relationships with the other modules. I wanted to remove a single relationship from the list of relationships. is any option to remove a single relationship instead of 'Clear Relationships' under reset module?

If you have created your relationship through Studio you should be able to delete it from there, so:
*- Admin -> Studio -> ~your_module~ -> Relations -> ~your_relation~ -> Delete*
In case you are not allowed you can use another method. You should first delete two files:
Metadata file:
custom\metadata\~relationship_name~MetaData.php
TableDictionary file:
custom\Extension\application\Ext\TableDictionary\~relationship_name~.php
Now you have to remove fields from both related modules:
custom\Extension\modules\~first_module_name~\ext\vardef\~field_name~.php
custom\Extension\modules\~second_module_name~\ext\vardef\~field_name~.php
P.S: Remember to backup before deleting any files

Related

Initial load creates my tables in the sym_x tables schema

After setting up a master-master replication on top of PostgreSQL , I tried to perform an initial load using:
./symadmin -engine octopusdb reload-node 2
My setup is:
1. I created all sym_x tables in a separate schema (replication).
2. I created all my application tables in other schemas of their own.
3. I inserted into sym_trigger.source_schema_name the suitable schema name for each application table.
Still, the initial load seem to create the application tables under the 'replication' schema instead of in their own schemas.
Is there some parameter I am missing for the properties file, or the initial load command?
So apparently for multi-schmea configuration,you need to create a separate record for each schema in sym_router (with a separate router_id, and appropriate target_schema_name), and for each table put a record in sym_trigger_router and sym_trigger with the appropriate router_id and schema name).
Also, once failed, I needed to remove everything from the tmp directory which is under the symmetric software, so the updates to sym tables will be recognized.

Composite Projects - handling additional columns

From this post....
http://blogs.msdn.com/b/ssdt/archive/2012/06/26/composite-projects-and-schema-compare.aspx
...it seems that (Same) Database References are a way to share common parts of a database.
If a specific database needs additional columns on a table from a (Same) Database Reference is there any way of handling that?
I was hoping you might be able to override the definition of a table from a Database Reference simply by re-declaring the table in the referencing Database Project.
e.g. if you had a Employee table in a Common Database project, a definition for Employee table in a Client Database referencing Common Database would override the definition in the Common project. Instead when you go to deploy the porject you get the error...
SQL71508: The model already has an element that has the same name dbo.Employee.
EDIT:
Anticipating the feedback below, the resolution I've made is to not use database references for the existing client databases. Instead I've created a structure as follows....
+OurCompanyDatabases
+Common
Common.sqlproj
+dbo...
+ClientA
+dbo....
+ClientB
+dbo....
ClientA.sqlproj
ClientB.sqlproj
So I've got multiple sqlproj files within the same folder and I include and exclude files from the projects as required.
So for example ClientA's Sales table has a ClientARewardsID column added I exclude the Sales table within the /OurCompanyDatabases/Common/dbo folder and create add a new Sales table within the /OurCompanyDatabases/ClientA/dbo folder.
This way Client A and Client B can retain the full use of SSDT update and deployment, whilst minimizing the duplication of sql scripts. I'm hoping this will reduce the cost of maintenance on the sites.
Going forward I will use database references and additional columns will be added in new tables with a foreign 1:1 foreign key relationship with the Common table.
No it doesn't support an inheritance type model and you can only really share complete objects so in your case you would have it structured like:
proj a - TableA
references - proj shared
proj b - TableA
references - proj shared
proj shared - TableXYZ
Then you can have two different definitions of TableA but still share all of the objects that are the same.
There is another option you could not include the table definition in SSDT or include one or the other and then handle any changes and the deployment yourself in post deploy scripts and use my filter (http://agilesqlclub.codeplex.com/) to stop ssdt deploying any changes to your table but this sort of invalidates one of the main reasons for using ssdt (merge type deployments for free).
ed
It's much safer and better practise to add a new table for the extra columns, and make its primary key a foreign key to the table it extends.

Adding a many-to-many view in EF6

I have an EDMX file which has both tables and views mapped from a SQL Server database. I am trying to add a view named CourseCompany to the EDMX file which serves as a many-to-many connection between two other views.
By looking at another many-to-many association using tables as an example, these are the non-default value properties on the association I added:
Association Set Name: CourseCompany
End1 Multiplicity: * (Collection of Course)
End1 Navigation Property: Companies
End2 Multiplicity: * (Collection of Company)
End 2 Navigation Property: Courses
Name: CourseCompany
But doing this produces this compile error:
Error 3027: No mapping specified for the following EntitySet/AssociationSet - CourseCompany
I made sure the views that this association is going between have their primary keys defined correctly in the EDMX. What do I need to do to add this association in the EDMX?
Follow these steps to resolve this problem:
Add the many-to-many view through the "Update Model from Database" tool.
Edit the newly added entity so that both fields have Entity Key set to true.
Add an Association to the EDMX and configure it as I noted in the question above.
Click on the Association link and go to the Mapping Details tab.
Select the view name in the Maps to dropdown and set the field mappings as well.
Delete the entity that was added in step 1.
This kind of error is often caused by not running the "Generate Database From Model" command (accessible from the context menu of the EDMX designer) after making changes to the design.
Running the tool (if it worked, it will update the SQL generation script) should cause the problem to go away.

Complex CakePHP queries

I need a data-filter based on a child model HABTM relation condition.
My table structure is as following:
Project hasMany TaskGroup hasMany Task hasAndBelongsToMany User.
I need my find function to get only the Projects with specific TaskGroups that contain Tasks assigned to some User.id. In other words, I need my Tasks filtered by User.id, and structured as Project -> TaskGroup -> Task. Is there a way Cake model bindings handle this, or do I need to write the joins manually?
You'll need to use Joins - see link for how to build joins in CakePHP:
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#joining-tables

How to update the Entity framework after adding a new Table to the database in MVC

Alright first i apologize if i used any wrong terms.
my problem is that i created a database then i made the models out of it (database first approach) afterwards I've added a new table called "accounts" for example.
of course i cannot use it in the controller like
var x = db.accounts.Tolist();
because its not included in the models.
i tried to "update the model from the database" from the model design panel but it didn't create any new class for the new table..
any idea ?
You need to make sure that on the "Add" panel, you select the new table you want to add:
Sometimes I find that when I have problems it's easiest to just delete all the tables from the edmx and re-add them all, or even just to re-create the edmx in its entirety.

Resources