> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/platform/guides/developer-guide/backend-developer-guide/section-1-create-project/create-database.md).

# Create Database

## **Overview**

Once PostgreSQL (v10) has been installed and the basic setup is done, we use Flyway to create the tables.

## **Steps**

### **Enable Flyway Migration**

1. Configure the below properties in the application.properties file to enable flyway migration:

```properties
spring.flyway.url=jdbc:postgresql://localhost:5432/birthregn
spring.flyway.user=birth
spring.flyway.password=birth #REPLACE
spring.flyway.table=public
spring.flyway.baseline-on-migrate=true
spring.flyway.outOfOrder=true
spring.flyway.locations=classpath:/db/migration/main
spring.flyway.enabled=true
```

2. Add the Flyway SQL scripts in the following structure under `resources/db/migration/main`:

![](https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-0cc0e9ee0f3e0cff7b0322e958c9e6d3291701d7%2Fimage.png?alt=media)

3. Add the migration files to the *main* folder. Follow the specified nomenclature while naming the file. The file name should be in the following format:

```
V[YEAR][MONTH][DAY][HR][MIN][SEC]__modulecode_ …_ddl.sql

```

Example: **V20180920110535\_\_tl\_tradelicense\_ddl.sql**

For this sample service, use the following SQL script to create the required tables.

{% code lineNumbers="true" %}

```plsql
CREATE TABLE eg_bt_registration(
  id character varying(64),
  tenantId character varying(64),
  applicationNumber character varying(64),
  babyFirstName character varying(64),
  babyLastName character varying(64),
  fatherId character varying(64),
  motherId character varying(64),
  doctorName character varying(64),
  hospitalName character varying(64),
  placeOfBirth character varying(64),
  timeOfBirth bigint,
  createdBy character varying(64),
  lastModifiedBy character varying(64),
  createdTime bigint,
  lastModifiedTime bigint,
 CONSTRAINT uk_eg_bt_registration UNIQUE (id)
);
CREATE TABLE eg_bt_address(
   id character varying(64),
   tenantId character varying(64),
   type character varying(64),
   address character varying(256),
   city character varying(64),
   pincode character varying(64),
   registrationId character varying(64),
   createdBy character varying(64),
   lastModifiedBy character varying(64),
   createdTime bigint,
   lastModifiedTime bigint,
   CONSTRAINT uk_eg_bt_address PRIMARY KEY (id),
   CONSTRAINT fk_eg_bt_address FOREIGN KEY (registrationId) REFERENCES eg_bt_registration (id)
     ON UPDATE CASCADE
     ON DELETE CASCADE
);
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digit.org/platform/guides/developer-guide/backend-developer-guide/section-1-create-project/create-database.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
