Lifetime: Switch the database connection when deploy automatically

Lifetime: Switch the database connection when deploy automatically

  

Hi there,


Is there any why to switch the database connection when deploying an application in Lifetime automatically?

Reason: The environment will be very large and user don't want to change each connection by PlatformRuntimeAPI or inside Service Center.


User want to set all the desired Database as following;

 1.On Development stage: "Development"."Table"

 2.On Test stage              : "Test"."Table"

 3.On Production stage    : "Production"."Table"


Notice: the "Table" will be more than 1,000 tables, so the API should support all the Table without changing a code. And the API would run automatically when the stage changed(deploy)(ex. Deployment -> Test, Test -> Development.)

I saw aDbConnection_Edit inside LifeTimeAPI but I don't have an environment to try this function. 


Anyone who ever use Lifetime, it will be very appriciate if you could give me an advise.

Thank you in advance.


Hello Chaiwat

Is your application using external entities? If so, are those imported into an extension and using a database connection you previously configured in ServiceCenter?

Hi Pedro,

Thank you for reply.

Yes. We are using external entities and import it as an extension in both development and test environment.


Pedro Cardoso wrote:

Hello Chaiwat

Is your application using external entities? If so, are those imported into an extension and using a database connection you previously configured in ServiceCenter?



Hi there. I was expecting that. The ideia is that you can have the extension associated with different connections in each environment.

If I understand you correctly, what you are asking for is what is supported by the platform out-of-the-box

Hello Chaiwat Meetanatharvorn.

Like Pedro Cardoso said, you can change the external database that is used by the extension for each environment in OutSystems.

One thing you should note is that by default that change only works if the tables have the exact same name, including schema. Going for your initial post it can be the case. You can try to work around this by changing the table name of the entities in Integration Studio from e.g., "Development"."Table" to "Table" and republishing.

Hope this helps.

Cheers,
Pedro Guimarães


Hi Pedro Cardoso and Pedro Guimaraes,


Pedro Cardoso: Thank you for the reply. I am not sure I understand  platform out-of-the-box. Is that mean, 

In 'Development' environment has database connection name 'Data Connector' that set username as 'Development'.

In 'Test' environment has database connection name 'Data Connector' that set username as 'Test'. 

And when I deploy my application that use 'Data Connector', it will automatically change the connection depend on each environment setting, Is that correct?


Pedro Guimaraes: First, Thank you for reply. 

You said that if the schema is different, I need to change the table name in Integration Studio for each Table.

That is the reason why I am asking for the help. I don't want to edit it manually because there is a risk on human-error. 

I want to make sure that every table's schema will automatically change to "Test" schema when deploying the application. 

Is there any why to inject the command while deploying as folowing;          
        Replace(connectionString,"Development","Test")

        Replace(databaseIdentifier,"Development","Test")      

I am sorry if I am asking too much. I would try by myself if I have an environment.

I really need a help. Thank you in advance.