The AMRIT-DB service is a Spring Boot application designed to simplify database schema management and cloning. Using Flyway for migrations, it ensures consistency and ease in setting up local environments, making it an invaluable tool for developers.
- Introduction
- Key Features
- Prerequisites
- Creating Migrations
- Build Configuration
- Run Configuration
- Running Migrations
- Common Issues & Troubleshooting
- Contributing
The AMRIT-DB service leverages Flyway within a Spring Boot framework to manage and clone empty database schema tables. It ensures that database structures remain consistent with application requirements, reducing setup time and preventing discrepancies.
- Schema Management: Automates database schema creation and version control using Flyway.
- Migration Scripts: Supports SQL-based migration scripts for defining tables, constraints, and relationships.
Ensure the following databases are created:
db_iemr
db_reporting
db_identity
db_1097_identity
Ensure you have the following installed before starting:
- Java 17
- Maven 3.6+
- MySQL 8
Flyway migrations are stored in the src/main/resources/db/migration
directory. Each schema has its own subfolder.
- Place new or updated migration scripts in the corresponding schema folder.
- Follow Flyway’s naming convention:
- Example:
V1__InitialSetup.sql
,V2__AddNewColumn.sql
- Example:
For subsequent changes, increment the version number, e.g., V3__<description>.sql
.
-
Setup Local Properties:
- Copy
common_example.properties
tocommon_local.properties
and update it for your environment. - File location:
src/main/environment
- Copy
-
Create Build Configuration in STS/Eclipse:
- Go to Run > Run Configurations.
- Select Maven Build and create a new configuration.
- Set the Base Directory to the
AMRIT-DB
module. - Set Goals to:
clean install -DENV_VAR=local
- Go to Environment tab and click Add. Set
Name : ENV_VAR Value: local
- Apply and run the configuration.
-
Setup Spring Boot Configuration:
- Go to Run > Run Configurations.
- Select Spring Boot App (STS) or Java Application (Eclipse) and create a new configuration.
- Choose the project and main class.
- Apply and run the configuration.
-
Verify Application:
- Access Swagger UI: http://localhost:8080/swagger-ui.html
-
Database Credentials:
- Add credentials in
common_local.properties
.
- Add credentials in
-
Run Migrations:
- Flyway automatically runs migrations at application startup if configured correctly.
- Start the application using:
mvn spring-boot:run -DENV_VAR=local
-
Migration Failures:
- Check SQL syntax and review the
flyway_schema_history
table for errors.
- Check SQL syntax and review the
-
Database Connection Issues:
- Verify details in
application.properties
.
- Verify details in
We welcome contributions! Please follow these steps:
Fork the repository. Create a new feature branch (git checkout -b feature/your-feature). Commit your changes (git commit -m 'Add some feature'). Push to the branch (git push origin feature/your-feature). Open a pull request.