Can Liquibase use DB2's multiple tablespaces? - db2

In DB2 LUW it is recommended that tables, indexes and "long objects" (ie LOBs) should be placed in separate tablespaces. Our existing SQL scripts have lines like this:
CREATE TABLE "APPLICATIONTABLE"(
APPLICATIONID INTEGER NOT NULL,
APPLICATIONNAME VARCHAR(30) NOT NULL
)IN USERSPACE1 INDEX IN USERSPACE2 LONG IN USERSPACE3;
In a changeset we can specifiy a tablespace:
<createTable tableName="APPLICATIONTABLE" tablespace="${tablespace.data}">
<column name="APPLICATIONID" type="NUMBER(4, 0)">
<constraints nullable="false"/>
</column>
<column name="APPLICATIONNAME" type="VARCHAR(30)">
<constraints nullable="false"/>
</column>
</createTable>
But not, as far as I can see, DB2's multiple tablespaces. Is there any way to do this?

You could use a sql change which liquibase doc describes as:
The ‘sql’ tag allows you to specify whatever sql you want. It is useful for complex changes that aren’t supported through Liquibase’s automated refactoring tags and to work around bugs and limitations of Liquibase. The SQL contained in the sql tag can be multi-line.
It looks like this (copied from the liquibase doc):
<changeSet author="liquibase-docs" id="sql-example">
<sql dbms="h2, oracle"
endDelimiter="\nGO"
splitStatements="true"
stripComments="true">insert into person (name) values ('Bob')
<comment>What about Bob?</comment>
</sql>
</changeSet>
EDIT:
Just saw another option after reading this answer.
You could use the modifySql tag. Maybe leave out tablespace info and just append it like this (untested code - just a suggestion):
<createTable tableName="APPLICATIONTABLE">
<column name="APPLICATIONID" type="NUMBER(4, 0)">
<constraints nullable="false"/>
</column>
<column name="APPLICATIONNAME" type="VARCHAR(30)">
<constraints nullable="false"/>
</column>
<modifySql dbms="db2">
<append value=" IN USERSPACE1 INDEX IN USERSPACE2 LONG IN USERSPACE3"/>
</modifySql>
</createTable>

This is something that is supported by the Datical extensions to Liquibase, but not in Liquibase itself.

I know this is 6 years old, but I thought I'd post this as another possible solution. From their site they give the following as example
<changeSet id="2" author="liquibase">
<createTable catalogName="department2"
remarks="A String"
schemaName="public"
tableName="person"
tablespace="${tablespace}">
<column name="address" type="varchar(255)"/>
</createTable>
</changeSet>
Then define the tablespace name on the command line. If you had multiple you could provide multiple -D options
liquibase -Dtablespace='tablespaceQA' update

Related

Properties allowed in Liquibase - Constraints

I am trying to add a new table in the DB using Liquibase.
I am putting Constraints inside the table definition and have a foreign key in it. Without having an extra addForeignKey code snippet.
So I am trying to use this. But it says onDelete is not allowed in constraints . Its also a little hard to find any documentation related to this. Other properties do get allowed though.
<createTable tableName="relationship_view_person">
<column name="view_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_view_person_reln" referencedTableName="configured_view" referencedColumnNames="view_id" onDelete="CASCADE" />
</column>
<column name="person_id" type="TEXT">
<constraints nullable="false" foreignKeyName="fk_person_view_reln" referencedTableName="persons" referencedColumnNames="person_id" onDelete="CASCADE" />
</column>
</createTable>
I get this error
cvc-complex-type.3.2.2: Attribute 'onDelete' is not allowed to appear in element 'constraints'.
Please checkout this documentation for add column in liquibase. And scroll till you are on Constraints tag section. You will find all the attributes allowed with liquibase constraints tag.
As per the error you are getting for onDelete is not allowed, please try using attribute deleteCascade="true" like below:
<createTable tableName="relationship_view_person">
<column name="view_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_view_person_reln" referencedTableName="configured_view" referencedColumnNames="view_id" deleteCascade="true" />
</column>
<column name="person_id" type="TEXT">
<constraints nullable="false" foreignKeyName="fk_person_view_reln" referencedTableName="persons" referencedColumnNames="person_id" deleteCascade="true" />
</column>
</createTable>
On running updateSQL it will generate the expected SQL query for you (which you can verify before executing it directly on DB):
CREATE TABLE public.relationship_view_person (view_id BIGINT NOT NULL, person_id TEXT NOT NULL, CONSTRAINT fk_view_person_reln FOREIGN KEY (view_id) REFERENCES public.configured_view(view_id) ON DELETE CASCADE, CONSTRAINT fk_person_view_reln FOREIGN KEY (person_id) REFERENCES public.persons(person_id) ON DELETE CASCADE);
Note: onDelete attribute works with addForeignKeyConstraint tag in liquibase. Find documentation for it here.
TL;DR
You said
I am putting Constraints inside the table definition and have a foreign key in it. Without having an extra addForeignKey code snippet.
As exception suggest you are not allow to set unknown element line onDelete with in <constraint> tag, furthermore the set of possible configuration with in <constraint> till the latest version (4.*.*) are as follow.
<!-- Attributes for constraints -->
<xsd:attributeGroup name="constraintsAttributes">
<xsd:attribute name="nullable" type="booleanExp"/>
<xsd:attribute name="primaryKey" type="booleanExp"/>
<xsd:attribute name="primaryKeyName" type="xsd:string"/>
<xsd:attribute name="primaryKeyTablespace" type="xsd:string"/>
<xsd:attribute name="unique" type="booleanExp"/>
<xsd:attribute name="uniqueConstraintName" type="xsd:string"/>
<xsd:attribute name="references" type="xsd:string"/>
<xsd:attribute name="referencedTableName" type="xsd:string"/>
<xsd:attribute name="referencedColumnNames" type="xsd:string"/>
<xsd:attribute name="foreignKeyName" type="xsd:string"/>
<xsd:attribute name="deleteCascade" type="booleanExp"/>
<xsd:attribute name="deferrable" type="booleanExp"/>
<xsd:attribute name="initiallyDeferred" type="booleanExp"/>
<xsd:attribute name="checkConstraint" type="xsd:string"/>
</xsd:attributeGroup>

Expand input suggestion width

Screenshot of the current width:
I'm trying to expand the suggestion popup above.
Since I want to use it in a FilterBar, the Input fields are small and the Table becomes kind of useless. When trying to change the width with the Inspector, it changes back immediately.
The demo code I'm using is rather simple.
<Input xmlns="sap.m"
showSuggestion="true"
showTableSuggestionValueHelp="false"
suggestionRows="{/ZSD_DebiaSet}"
width="200px">
<suggestionColumns>
<Column popinDisplay="Inline" demandPopin="true">
<Label text="Name"/>
</Column>
<Column hAlign="Center" popinDisplay="Inline" demandPopin="true" minScreenWidth="Tablet">
<Label text="Product ID"/>
</Column>
<Column hAlign="Center" popinDisplay="Inline" minScreenWidth="Tablet">
<Label text="Supplier Name"/>
</Column>
<Column hAlign="End" popinDisplay="Inline" demandPopin="true">
<Label text="Price"/>
</Column>
</suggestionColumns>
<suggestionRows>
<ColumnListItem>
<!-- ... -->
</ColumnListItem>
</suggestionRows>
</Input>
Controls extended from sap.m.Input (i.e. including sap.m.MultiInput) have a property called maxSuggestionWidth which will let you have a wider suggestion table than the actual width of your input. Check the property here: https://openui5.hana.ondemand.com/api/sap.m.Input#methods/setMaxSuggestionWidth
If set, the value of this parameter will control the horizontal size of the suggestion list to display more data. This allows suggestion lists to be wider than the input field if there is enough space available. By default, the suggestion list is always as wide as the input field.
Note: The value will be ignored if the actual width of the input field is larger than the specified parameter value.
I added this property with value 500px (just for testing) and the result is the following (The Input width is 200px):
I think this is what you are looking for ^^ Hope it helps!

Edit custom customer group attribute (column) in Magento 2

Bonjour !
I try to edit some custom customer group fields in my Magento 2.3 but I don't know how to start.
I already have added some columns and displayed it in admin back-office with a module.
view/adminhtml/ui_component/customer_group_listing.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="customer_group_columns">
<column name="siret">
<settings>
<filter>text</filter>
<label translate="true">SIRET</label>
</settings>
</column>
<column name="code_client">
<settings>
<filter>text</filter>
<label translate="true">Code client</label>
</settings>
</column>
<column name="zipcode">
<settings>
<filter>text</filter>
<label translate="true">Code postal</label>
</settings>
</column>
</columns>
</listing>
But now I want on the update form to have the capability to modify this fields (siret, code_client, zipcode)
Screenshot of the BO
For exemple, here I only have 2 fields but I want to add for example the zipcode in the form.
Screenshot of the update form
Thanks :)

EF 6 query contains unmapped columns, breaking the query

I have an EDMX (Entity Framework 6.1.3) that I'm using to query two different databases. There are some minor differences between the databases but I only want the common columns. I generated the EDMX from Database A, and removed the columns that were not in Database B from the Diagram and regenerated the code.
If I query database B the query contains the columns I removed, although the final SELECT does not. This means that the query fails.
The table mapping shows the columns, but with nothing on the Value/Property side:
The exception is:
System.Data.Entity.Core.EntityCommandExecutionException : An error occurred while executing the command definition. See the inner exception for details.
----> System.Data.SqlClient.SqlException : Invalid column name 'ValidFromDate'.
Invalid column name 'ValidToDate'.
Invalid column name 'LastPulled'.
Invalid column name 'IsCurrent'.
The query that is being sent to the server is:
SELECT TOP (1)
[c].[FirstName] AS [FirstName],
[c].[LastName] AS [LastName],
[c].[HomePhone] AS [HomePhone],
[c].[WorkPhone] AS [WorkPhone],
[c].[MobilePhone] AS [MobilePhone],
[c].[Email] AS [Email],
[c].[Fax] AS [Fax]
FROM (SELECT
[Person].[FirstName] AS [FirstName],
[Person].[LastName] AS [LastName],
[Person].[HomePhone] AS [HomePhone],
[Person].[WorkPhone] AS [WorkPhone],
[Person].[MobilePhone] AS [MobilePhone],
[Person].[Email] AS [Email],
[Person].[Fax] AS [Fax],
[Person].[ValidFromDate] AS [ValidFromDate],
[Person].[ValidToDate] AS [ValidToDate],
[Person].[LastPulled] AS [LastPulled],
[Person].[IsCurrent] AS [IsCurrent]
FROM [dbo].[Person] AS [Person]) AS [c]
As you can see there is an inner-query which contains the additional columns.
At this point I'm kind of stumped as to why this is happening. How do I remove these columns from both sides of the mapping, or otherwise stop EF from putting unwanted columns in ANY part of the query?
When you use the EDMX designer and simply delete a column from an entity - this does not fully remove the column from the EDMX. Assuming you truly want it gone, you can open the EDMX file with a text editor and remove it by hand. To make sure that your manual changes trigger a rebuild of your auto-generated classes, edit it in Visual Studio and you shouldn't have an issue.
Right-click the EDMX in solution explorer
Open With...
XML (Text) Editor
I would expect if you were to open the EDMX, you would find something that looks like:
<EntityType Name="Person">
<Property Name="FirstName" Type="varchar" />
<Property Name="LastName" Type="varchar" />
<Property Name="HomePhone" Type="varchar" />
<Property Name="WorkPhone" Type="varchar" />
<Property Name="MobilePhone" Type="varchar" />
<Property Name="Email" Type="varchar" />
<Property Name="Fax" Type="varchar" />
<Property Name="ValidFromDate" Type="datetime" />
<Property Name="ValidToDate" Type="datetime" />
<Property Name="LastPulled" Type="datetime" />
<Property Name="IsCurrent" Type="short" />
</EntityType>
And you would just remove the bottom 4 columns, save and close, and rebuild the project.
EDIT: In case anyone in the future references this answer, if you do not first delete the column in the designer (like the OP did in this case), there will be two other instances of the column(s) in the XML that you would also need to remove in order for it to compile.
Thanks to #Borophyll for pointing me in roughly the right direction. Although their answer was not the solution to my issue, it did allow me to see the actual issue.
in the EDMX file there is also a entry that looks like this:
<EntitySet Name="Person" EntityType="Self.Person" store:Type="Tables" store:Schema="dbo">
<DefiningQuery>SELECT
[Person].[FirstName] AS [FirstName],
[Person].[LastName] AS [LastName],
[Person].[HomePhone] AS [HomePhone],
[Person].[WorkPhone] AS [WorkPhone],
[Person].[MobilePhone] AS [MobilePhone],
[Person].[Email] AS [Email],
[Person].[Fax] AS [Fax],
[Person].[ValidFromDate] AS [ValidFromDate],
[Person].[ValidToDate] AS [ValidToDate],
[Person].[LastPulled] AS [LastPulled],
[Person].[IsCurrent] AS [IsCurrent]
FROM [dbo].[Person] AS [Person]</DefiningQuery>
</EntitySet>
And that's where the weird sub-query was coming. I think the reason is that the table has no primary key as it is part of a staging database.
I just deleted from the SELECT statement the last four columns and everything worked.

Liferay, ServiceBuilder, what's the scope for attributes userId, companyId, userId

Although I've developed some services with Liferay ServiceBuilder, I'm not quite sure I understand the point of using the attributes:
userId
companyId
groupId
Note that these attributes are available through the PortalRequest.
Following the basic tutorials, you are instructed to create these attributes for every entity, and take care to set them on 'add' functions. But thinking of it, I've not ever seen any tutorial or referenced code where these attributes are used on data retrieval (Finder methods, dynamic queries, or custom queries either)
So what's the point on keeping this information ?
Are these attributes used automatically somehow under some convention or scope ? Something like, the Liferay's default Finders using them when they are available through the PortalRequest ?
Or is it up to the developer to use them on every Select, E.g. are all the single-parameter Finders practically useless on multi-instance Portals (since the companyId attribute should be used on every Finder method) ?
Or is it just a good practice to keep this structure for database extendability, auditing, indexing or something else I'm totally missing ?
These attributes are necessary when you use your entities for example on staging environment. The groupId specifies to which environment the entity belongs to. Meaning of userId is obvious and as for companyId it is the site identifier. So IMHO these attributes are quite important when you have multiple sites on one portal, when you have staging env. enabled etc..
Suppose you have a new table and you want to set UserId in your table then it is necessary but otherwise I don't think these attributes are neccessary.
I have created service builder
<entity name="FaoEsalesCustomer" local-service="true" remote-service="false" table="fao_esalecustomer">
<!-- PK fields -->
<column name="esaleCustomerId" type="long" primary="true" />
<!-- Audit fields -->
<column name="createdBy" type="long" />
<column name="createdOn" type="Date" />
<column name="modifiedBy" type="long" />
<column name="modifiedOn" type="Date" />
<!-- Other fields -->
<column name="customerName" type="String" />
<column name="address" type="String" />
<column name="ph" type="Integer" />
<column name="categoryId" type="long" />
<column name="categoryName" type="String" />
<column name="quantity" type="Double" />
<column name="price" type="Double" />
</entity>