How to set default_schema in jhipster app with postgresql database? - jhipster

I'm using jhipster to develop an application and now I want to use an existing postgres database. So I choosed to add a new schema to the database and now I want to set in my application_dev.yml file the default schema. For that I tried this:
properties:
hibernate.default_schema: My_SCHEMA
still not working but when I do
liquibase:
default-schema: My_SCHEMA
it's working.
How to have the same result using
spring.jpa.properties.hibernate.default_schema=My_SCHEMA
Thanks in advance !

Related

How can i configure Mongoose to automatically create objects in my mongoDB on app start if none is found?

I am coming from a Java Hibernate frameworks, where an sql script can be written and added to a project, with the intentions of creating objects in my Mongo Database when the app runs and no data was found in a specific database table. I am using Mongoose presently with mongoDB, and i want to initialize my mongoDB table with objects if none is found. Initially i achieved this my creating an object and calling the new mongoose.save(obj) inside my app.js which is my start up file. But is there a cleaner way one already supported by Mongoose, or is this my best bet ?

How to specify a schema name in the Postgres URL for connecting to a PostgreSQL database on Heroku

I am connecting my parse-server application to a PostgreSQL database hosted on the Heroku-PostgreSQL service.
My database is with a schema called gc which is different to the default public schema on Postgresql.
I used the following to connect to the database from my parse-server application.
"postgres://{USERNAME}:{PASSWORD}#{HOSTNAME_ON_AWS}:5432/{DATABASE_NAME}?ssl=true"
But the issue was it was connected to the public schema but not the gc schema I wanted.
Is there a way to specify the schema name in Postgres URL?
I don't think you can,
what you can do however is associate a schema search path with a database user, so if you want a different schema you'd need to use a different username to connect as.
SQL:
alter user fred set search_path to 'gc';
I attach the parameter options=-csearch_path=XXX to the URI. It works.
psql "postgresql://user:pwd#127.0.0.1:6789/postgres?options=-csearch_path%3Dabc"
It shows the current schema below.
postgres=> show search_path;
search_path
-------------
abc
(1 row)
And take notice that I use the URLencode for the character =. Its URL encoding is %3D. Otherwise, you can't get the correct result in the shell.
Here are some references:
https://www.postgresql.org/docs/current/libpq-connect.html
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

Sequelize table validation and stop creating table

I am using sequelize ORM in nodejs. I have two apps. One app is only for database related task like creating tables and migrations (app1). Other app is rest api (app2). I am using sequelize in app2.I dont want to create table using app2 and i want to throw error here if table doesnt exist or schema is not the same. Is this possible using sequelize?
If you dont want to create the table in your app2, then just dont put the sequelize.sync() code. (if you're using migration and the sequelize-cli, then dont do sequelize db:update before launching your app2)
Concerning the error, if a table is not created, you will have errors when trying to use the schema !
I don't think there is a "clean" way of checking if the schema is inline with yours.

Modified entites are not reflecting in database

I have created a Entity for jhipster Microservice Gateway project.
Tried to modify the entity by adding new fields later. Its corresponding Java classes and Angular files got updated. But, the new field is not added in the database table.
Did i miss any other configurations ? Thanks in advance !
the database changes are done by liquibase, i.e. you need to have a look under
src/main/resources/config/liquibase/
for master.xml. JHipster is adding all the scripts that need to be run when you start your app in master.xml.
When you add new fields over comand line, then the generator is modifing your master.xml by adding a new change or is just updating an existing change. All the changes are located under in the folder changelog which is on the same level as master.xml.
I got it now. I failed to add hibernate statement under jpa in application.dev.yml.
I have added " hibernate.hbm2ddl.auto: update" under jpa in application.dev.yml file. And the field got inserted into mysql DB table.

Sequilize/Umzug: where to store a state of a database schema?

So, I want to write an application which use some data migration. Where should I store a current state of db?
For example: I have a production server and my development machine. I wrote an application and 3 migrations for it. When I deploy the application server also runs 3 migrations.
Now I'm going to write the 4th migration. How does server recognize that it need to run only 4th migration and it already run previous 3 migrations?
Ref https://github.com/sequelize/cli
sequelize init:migrations
will generate migration folder where you need to write migrations and
There are three types of storage that you can use: sequelize, json, and none.
sequelize : stores migrations and seeds in a table on the sequelize
database
json : stores migrations and seeds on a json file
none :
does not store any migration/seed

Resources