Is there a way to generate jHipster code without the Liquibase? Or to Disable the Liqibase ? JHipster 4.7.0 - jhipster

Is there a way to generate jHipster code without Liquibase?
Or Is there a jHipster generator for database scripts in some kind of separate project of database scripts like in Oracle, MySQL, P SQL etc.
What I mean is Liqibase does not meet my needs, like I want to create tablespaces for my Oracle DB, create a user and grant privileges to it and then create my SQL scripts with in pure SQL not in Liquibase XML file as I want my table data to reside in my tablespace and want to specify the size of columns based on my requirements. And when I'm done with creating the SQL file I just have to run the jar file for all the DB work.
If there is not an option for generating schema without Liquibase. I'm considering disabling the Liquibase and generate the tables manually. Can I disable the Liqibase? There are some online suggestions but for jHipster 3.12 but I have not tried it yet.
Disable Liquibase temporarily in JHipster 2.26

Yes you can use the no-liquibase profile (here is the documentation), and Liquibase will not run anymore
However, JHipster will still generate the Liquibase files for you: you can just ignore them, or even delete them
I personally often use that profile, even if I use Liquibase a lot, as this speeds up deployment (of course, I only use it when I don't modify my database, but I'm not modifying it all the time). So this is nice trick to know, whether you like Liquibase or not.
Then, I'm pretty sure you can do your database-specific scripts with Liquibase, or run them before Liquibase, so maybe this is another solution you could use.

Related

Is Possible to use Flyway instead of Liquibase with JHipster?

A few months ago, I had an opportunity of working with Flyway. Flyway is straightforward for anyone who knows SQL. It is far easier to use native SQL statements in a Flyway DB change file than using XML in a Liquibase DB change files. I hope there is at least an option of DB refactoring tool so that people can use Flyway if they like.
It is possible, but you will have to implement it yourself. There is no Flyway code anywhere in the generator.
Luckily, it's fully supported by Spring Boot (Flyway docs). Flyway also has a docs page for Spring Boot to get started.
JHipster relys a lot on Liquibase's features, for example the ability
to do a diff of the JPA model with the database (which is something
Flyway doesn't have)
So It will not be supported in near future atleast, as it would also
break JHipster current dev workflows.
Here you can find reference for this.

how to integrate a monolithic jhipster application with another jhispter application. ?- Jhipster

I have made three different applications in j JHipster with monolithic. I need to merge these applications. I know that by using micro-services my quest can be easy but the current requirement is to do the merging with the monolithic pattern only.
I need to merge two applications with another or main application. I am using MySQL as database. I don't know where I need to change and how. Please help me out, I am a newbie in this scenario.
i tried to create a java file for setter getter methods and and a dao file for three databases and now in the main class file and am trying to take every dao file as an array of object and integrate it and put it into the third db.is it possible.i wanted to show the code bt,since i am new not able to maintain the coding standards to show.
by this i way i tried to involve three databases in a single scenario and want to complete my query through CRUD model.
as you already pointed out, the proper way of merging here would be using the microservice option, which you cannot take, as you are forced to use monolithic architecture...
almost automatic merge
if you did not changed anything to your code, after generating the entities, you just can put the contents of your applications .jhipster directory into one, and run yo jhipster --with-entities to regenerate the entities in one application. You should keep in mind, you will have to take a look at your main/resource/config/liquibase folder, to set the migration ids properly.
manual merge
For this you should be more experienced in the underlying technologies, as you will have to:
recreate your entity classes
recreate zour DAO/Repositories
(maybe) recreate your services, or service implementations
recreate your REST controllers
do a proper liquibase migration
provide some tests
migrate the frontend code, by adding states, components, templates etc..
the most of these things you just can copy paste already generated code.
For more information, you should ask more precise, what is not working, if you already tried something...

Common practice for database schema load on Bookshelf.js/Knex.js

Both ActiveRecord (from Rails) and Sequelize (another node.js ORM) provide a way to initialize a database, creating the table structures from the model definitions. Rails does that through the rails db:schema:load command, while Sequelize has the sync() method that does the same. By using that, we don't need to run the entire migration stack of the application to start a fresh database, neither save SQL dumps on the project repository.
Coming from this background, I was expecting Bookshelf.js or Knex.js to have some kind of similar functionality, but I couldn't find it on the documentation of both projects.
I decided then to take a look at the source code of the Ghost blogging engine, which uses Bookshelf, and I found out that they treat the database initialization inside their own codebase:
https://github.com/TryGhost/Ghost/blob/e40290a/core/server/data/schema/schema.js
https://github.com/TryGhost/Ghost/blob/e40290a/core/server/data/migration/populate.js
https://github.com/TryGhost/Ghost/blob/e40290a/core/server/data/schema/commands.js
I'd like to avoid having to write my own code to treat things like this specially because other options like Sequelize offer this out of the box.
Is there any common practice, plugin or library recommended for database schema loading on Bookshelf?
I think you were on the right track and maybe just missed the docs.
http://knexjs.org/#Migrations
For loading a schema, you can run the migration stack if the migrations are written to be idempotent.
Another option is to use the database's export and import features. For example: https://www.postgresql.org/docs/9.1/static/app-pgdump.html
Rails achieves its migrations by having two rake tasks db:schema:dump and db:schema:load. Dump will dump your db schema to a local schema.rb file in a custom ruby format. db:schema:load loads that file.
So you could achieve something similar using pg_dump and pg_restore and an npm package script. Just make the script use node's exec method to call pg_dump and dump to the same file every time.

Schema and data migrations for node js

Is there any tool that works similar to Django South, but for Node?
Now I'm working with Sequelize. If I got it right, Sequelize does not have an option to create migration files based on existing models.
So, to create a new model/table, the steps are:
Create model with sequelize model:create <model meta>.
Edit generated migration file - add actual code for creating tables
in DB under up section.
Run migration with sequelize db:migrate.
I'm looking for something that can create migration files based on existing models, manage it similar to what South can do for Django.
Is there any option?
I have written a step-by-step guide on how to auto-create migrations with Sequelize in another post. Here is a summary...
The closest thing with Sequelize is
Sequelize Auto Migrations.
It allows you to have an iteration cycle like the following:
Create/update model -- by hand or with sequelize-cli)
Run makemigrations to auto-generate up and down migrations
Repeat as necessary
While this is very helpful, I've found it to be lacking in some critical areas:
The down migrations can be created incorrectly. So it may try to drop a table before its dependent tables have been dropped.
There are certain configurations around multi-field indexes that it has not correctly output.
There are currently 10 outstanding PRs, so it seems like a few additional contributors are attempting to make it more production-ready... but I've yet to find anything as clean and reliable as Django Migrations (formerly Django South).
TypeORM supports model based migrations. It can sync your db to your models directly, it can also create migration files too.
I think prisma is another option. It doesn't seem like that popular but it's a promising one.
Either way, it's just ridiculous that there are no solid tools for this. I've worked on django and .net projects in the last years and creating migrations is just easy with them. But when you try to use node.js for backend, you get stuck at a lot of points.
I was using sequelize and when I saw there was no official way to create automatic migrations from models, I've dropped using it. Maintaining your models with manually written migrations becomes very hard in my experience.
Now my only alternative is TypeORM and it just bugs me there is no other alternative in case TypeORM just goes unmaintained or if I want to use another library etc.
I'm seriously thinking dropping using node.js for backend. Yet, there are good tools to create projects integrated with modern front-end tools (like Next.js), finding a good orm is a big problem.
Take a look at https://typeorm.io/#/migrations/generating-migrations. I am in the same situation you was 4 years ago.
My options:
Waterline just for ORM and diff tool (like dbdiff) to make a file with differences from a new schema (generated by waterline migration with 'drop') vs production schema. With that output, you run query by query in a safe mode.
Prev option plus knex migrations. But you have to make your own migrations files. Knex doesnt have a schema file to compare but there is a request feature https://github.com/knex/knex/issues/1086.
Using sails but change waterline for sequalize and give a try at the #paulmest answer.
Use sails but change waterline for typeorm an use that auto generated.
Over the years, my team has tried Sequelize and TypeORM, but neither of them were great experiences. TypeORM had tons of cryptic problems and thousands of issues are unaddressed/open for years on end. Sequelize was generally fine, but lack of type support made it time-consuming to work with.
For the last 1.5 years, my team has been using Hasura. It's honestly been a breath of fresh air. Hasura's migration system is pretty barebones compared to Django South, but it is straight-forward and has a clean happy path.
You can use the Hasura Console (a localhost web editor) to create tables and add/remove columns. Those changes will be automatically distilled into schema changes stored in .sql files in a migration directory. You can modify these files. You can run a migration command from the command line to apply them when you want.
Since Hasura is a GraphQL engine, it also comes with a schematized SDK that is TypeScript compatible so you get incredible editor support.
All of this and much more is available in the open source version of their product. We have not needed to pay for any higher tier.
You can find more information here: https://hasura.io/docs/latest/graphql/core/migrations/index.html

How to turn off Entity Framework CF Migrations for an environment

Is it possible to turn off Entity Framework using the web.config? In the application I'm developing we have the following environments
Development
Continuous Integration
Integration Testing
Production
The Integration Testing and Production databases are managed by a database administrator, so we have to send them a script to make changes to the database.
I've spent hours Googling and looking through old projects, and I can't find how to do this or remember if we ever turned off migrations on the old projects in the first place.
From the lack of information I'm doubting if what I'm asking is needed or possible, but there is something in the back of my head that's annoying me about this so I thought I'd ask the experts.
The easiest method is to simply delete the dbo._MigrationHistory table from these environments. If that table doesn't exist, then only an "initial" migration can ever be generated against that database, which will fail if someone tries to actually apply it to a database with existing tables.
You could set the database initializer in the config file as described at the bottom here, so you can have an updating initializer in the environments you want

Resources