Skip to content

Commit

Permalink
Add instructions for postgresql timeseries migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
GodVenn committed Oct 3, 2023
1 parent 1f8965d commit 58d7b9a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,35 @@ This is done automatically as part of the promotion workflows
([promoteToProduction](https://github.com/equinor/flotilla/blob/main/.github/workflows/promoteToProduction.yml)
and [promoteToStaging](https://github.com/equinor/flotilla/blob/main/.github/workflows/promoteToStaging.yml)).

## Database setup

If reseting database, but still using postgresql (removing old migrations and adding them manually again), you need to manually add some migrations commands for the timeseries db.

Add the following to the **top of the first migration's** `Up()` method:

```
// MANUALLY ADDED:
// Adding timescale extension to the database
migrationBuilder.Sql("CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;");
//
```

**For each of the timeseries tables**, add the following to the **bottom of the last migration's** `Up()` method:

```
migrationBuilder.Sql(
"SELECT create_hypertable( '\"TIME-TABLE-NAME\"', 'Time');\n"
);
```

Example:

```
migrationBuilder.Sql(
"SELECT create_hypertable( '\"RobotBatteryTimeseries\"', 'Time');\n"
);
```

## Formatting

### CSharpier
Expand Down

0 comments on commit 58d7b9a

Please sign in to comment.