developer
developer

Reputation: 77

Creating users with Flyway migrations

I believe database migrations are related to the objects of the database like tables, views, data etc.

Can we add / edit users and change their login passwords as part of the migration with flyway ? Is it a considered best practice?

Upvotes: 1

Views: 2729

Answers (2)

Julia Hayward
Julia Hayward

Reputation: 2155

Yes, anything that is valid SQL can be run in a migration.

However, the usual use case for Flyway is that migration scripts are stored somewhere permanent so that you have a trail of how the database got to its current state. You will need to take care that credentials are not accidentally exposed in source control (including history), collections of migration scripts on build servers, or anywhere else.

Upvotes: 3

Chris Savory
Chris Savory

Reputation: 2755

According to the Flyway docs:

SQL-based migrations are typically used for

  • DDL changes (CREATE/ALTER/DROP statements for TABLES,VIEWS,TRIGGERS,SEQUENCES,…)
  • Simple reference data changes (CRUD in reference data tables)
  • Simple bulk data changes (CRUD in regular data tables)

So yes the migrations can contain DML as well DDL.

Upvotes: 2

Related Questions