The way Cuba Studio handle DB scripts of addons seems not always right

Hi,

Previously, while add an addon to main project, the DB scripts of the addon will be copied to new project.

Recently, we found that while add an addon to main project, the DB scripts of the addon will not be copied, instead, cuba studio generates scripts for addon in the main project.

This seems not always right, for example, I have one addon, it contains scripts that cuba studio cannot generate, like “create or replate view my_view as select xxxxx”, or “CREATE EXTENSION IF NOT EXISTS “uuid-ossp”;”, or some updates sql which update live database for upgrade.

For the case when use an addon which not familiar with such details, or update an addon with special DB changes, the main project cannot get the correct DB scripts generated.

Is there something changed in studio? How to handle the case mentioned above?

Thanks~

Hi,
I’ve checked with Studio 13.1 and CUBA 7.2.2, and Postgres DB in the add-on and it works as expected.

If my add-on uses Postgres DB, and main project uses other (HSQL) database - then project generates missing database scripts for the add-on for HSQL.
If switch project to use Postgres for its main data store - then project transparently uses inherited addon’s DB scripts, including custom SQL that I put there:

image

Also could you make sure that artifact with database scripts (addonname-core-0.1-SNAPSHOT-db.zip) was successfully published?

Hi,
We found that it was caused by no clean task run before update/createdb task.

After run clean before update/createDb, the dbscripts copied successfully.

@AlexBudarov

Without clean, the db scripts may not copied successfully, should this be documented or check whether an issue?

Hi,
Can you please describe exact steps?

  • create project
  • create database
  • attach add-on
  • generate DB scripts or run CUBA application

What is the sequence of steps to reproduce the problem?

Hi,
This is my step:

  1. Create project and database ,attach add-on.
  2. Do other develop work of the project regularly.
  3. Do database change in the add-on, and publish new version.
  4. attache add-on new version.
  5. updateDB without clean, then dbscripts not copied.

I reproduced the problem and created ticket for the CUBA gradle plugin:

2 Likes