I. Questions If you have developed a Service-builder type of project (I am sure you will develop this type of project), The database table structure of the business entity used is configured in Service.xml, and then executes the code that Build-service generates the relevant DAO layer (this article does not clearly refer to the concept of DAO), then deploys the project, and the portal automatically executes the SQL statement that created the database table. In 62 development, after modifying the Service.xml, execute Build-service, deploy the project, the portal will help you to automatically modify the table in the data according to the change of the table structure, and keep the data as much as possible (I tried, add the field no problem, others forget). is a bit of background knowledge, but in DXP development, according to the so-called database protection mechanism, Even if we modify the table structure in Service.xml and redeploy the project, the portal will not help us modify the database table structure, even during the development phase. If you want the portal to modify the table structure, you have to follow the way of this article, that is: every time you modify the table structure, it is necessary to write the corresponding database upgrade statement, because the process is more complex, I have not followed the article operation, looked dizzy, but in order to modify the database table structure, why should I write extra code? So I studied the process of Lifeay executing tables.sql and found a way to force the portal to execute tables.sql. Two , solutions First I just say the way, let the anxious use of the people directly use, and then I share the study process. Prerequisites: Portal is the method for connecting MySQL boot: 1. Modify Service.xml, run build-service 2. connect MySQL database, find servicecomponent table, Delete all data with the same value as the namespace value in your Service.xml 3. Delete all the tables that have been created for the corresponding namespace. 4. Execute verify  inside the Server administrator;d atabase tables of all plugins 5. Deployment Project, The portal will re-execute the Tables.sql, and the table will re-establish (add: After deploying the project, I see the output "running xxxx Sql scripts ", but there is still no table in the database, then execute verify database tables of all plugins again to see the table in the database) Research process Next I'll share the research process: we may have noticed that when you deploy a project of a new Service-builder type, the console outputs a statement "Running xxxx sql scripts ", Search for" sql scripts "in the Portal source code, Found in the Servicecomponentlocalserviceimpl.java class, if it is a deployed project, deploy again, you will only see "upgrading xxxx database to build number ? " Such information, the database must have a table to record which projects have been deployed, BuildNumber is how much, so we found the Servicecomponent table, view the data, just have we used the namespace, delete the data, redeploy the project, Found and unable to execute the tables.sql file, we guessed that there might be some cache records in memory for this data, and then executed the Verify database tables of all plugins, Deploy again, finally can execute the tables.sql. Servicecomponentlocalserviceimpl.java is the core of the class, if you carefully study the code of this class will have other gains, here is only one example: you can see that this class actually supports the operation of upgrading the database, As long as the previous tablesql and the new TAblesql inconsistent, will perform the upgrade database operations, according to our thinking, we deployed two times the tables.sql is inconsistent, why not execute this code? Debugging finds that the Tablessql variable is always an empty string (not null, a string with a value of ""), so the upgrade database operation is never performed, and the CDATA field of the Servicecomponent table also shows that DXP does not log tables.sql statements. As for why the implementation of Verify database tables of all plugins, can be re-implemented, I did not go further down the study, Refer to the Verifyplugintables () method in Editservermvcactioncommand.java. Analysis to this end, my analysis may not be comprehensive, there may be errors, please criticize the ha.
Liferay 7.0 How to get the portal to re-execute after modifying service.xml tables.sql