Skip to content

Conversation

@pregnantboy
Copy link
Contributor

@pregnantboy pregnantboy commented Jun 11, 2025

Tiles v2

Staging

  • Ensure new aurora db is created with Pulumi
  • Add env vars into paramater store
  • Add launch darkly whitelist group
  • Run migration

Prod

  • Ensure new aurora db is created with Pulumi
  • Add env vars into paramater store
  • Add launch darkly whitelist group
  • Run migration

@pregnantboy pregnantboy requested a review from a team as a code owner June 11, 2025 06:23
@linear
Copy link

linear bot commented Jun 11, 2025

@pregnantboy pregnantboy marked this pull request as draft June 11, 2025 06:26
@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Jun 11, 2025

Datadog Report

Branch report: tiles-v2/trunk
Commit report: fc6950b
Test service: plumber

✅ 0 Failed, 970 Passed, 0 Skipped, 3m 10.84s Total Time
⬆️ Test Sessions change in coverage: 1 increased (+0.5%)

@pregnantboy pregnantboy force-pushed the tiles-v2/trunk branch 2 times, most recently from 16cd657 to fc6950b Compare July 5, 2025 12:04
…#972)

### Changes

Added a separate Postgres database for tiles functionality with corresponding configuration.

### What changed?

- Added environment variables for tiles Postgres configuration in `.env-example`
- Added a new `tiles-postgres` service in `docker-compose.dev.yml` running on port 5431
- Created a new volume `plumber-tiles-postgres` for persistent storage
- Extended the app configuration in `src/config/app.ts` to include tiles Postgres settings
- Created a new file `src/config/tiles-database.ts` that initializes a Knex client for the tiles database

### How to test?

1. Update your local `.env` file with the new tiles Postgres variables
2. Run `docker-compose -f docker-compose.dev.yml up -d` to start the new tiles-postgres service
3. Verify the tiles-postgres container is running and healthy
### Changes
Added a new `db` column to the `table_metadata` table to distinguish between PostgreSQL and DynamoDB tables.

### What changed?

- Created a new migration file `20250506071427_add_table_metadata_db_column.ts` that adds a `db` column to the `table_metadata` table with a default value of 'ddb' and not nullable constraint
- Updated the `TableMetadata` model to include the new `db` property with type 'pg' | 'ddb'

### How to test?

1. Run the migration
2. Verify the column exists in the database schema
3. Check that existing records have the default 'ddb' value
…operations (#974)

### Changes

Added PostgreSQL support for Tiles with streaming capabilities and ULID for row IDs.

### What changed?

- Added new dependencies: `pg-query-stream` and `ulid` to support PostgreSQL streaming and monotonic ID generation
- Created new PostgreSQL-specific implementation files for table operations:
  - `table-functions.ts` - For creating tables
  - `table-column-functions.ts` - For managing table columns
  - `table-row-functions.ts` - For CRUD operations on table rows
- Implemented types for table operations in `types.ts`
- Introduced ULID (Universally Unique Lexicographically Sortable Identifier) for row IDs

### How to test?

1. Install the new dependencies with `npm install`
2. Test the PostgreSQL implementation by running the existing integration tests
### Changes

Reorganized table row models by moving them from `/models/dynamodb/table-row` to `/models/tiles/dynamodb/table-row` and separated types into a dedicated file.

### What changed?

- Moved table row models and functions from `/models/dynamodb/table-row` to `/models/tiles/dynamodb/table-row`
- Extracted types from `/models/dynamodb/table-row/types.ts` to `/models/tiles/types.ts`
- Updated all imports across the codebase to reference the new file locations
- Moved helper functions from `/models/dynamodb/helpers.ts` to `/models/tiles/dynamodb/helpers.ts`
- Updated all test files to use the new import paths

### How to test?

1. Run the existing test suite to ensure all functionality works as expected
2. Verify that all table operations (create, read, update, delete) still function correctly
3. Check that the integration tests pass with the new import paths
### Changes

Added a factory pattern for database operations with support for PostgreSQL and DynamoDB.

### What changed?

- Created a factory function `getTableOperations` that returns the appropriate database implementation based on the database type
- Implemented `DynamoDBTableOperations` class with table row operations and no-op functions for unsupported operations
- Implemented `PostgresTableOperations` class with full support for table, column, and row operations
- Both implementations conform to the `TableOperations` interface
…etAllRows payload (#977)

### Changes
Added support for multiple database types in the table system with a factory pattern for database operations.

### What changed?

- Implemented a database type factory pattern with `getTableOperations()` to support multiple database backends
- Added a `databaseType` parameter to the `CreateTableInput` GraphQL type
- Updated all table operations (create, read, update, delete) to use the factory pattern
- Modified row data format to use CSV for network transfer to reduce payload size
- Added conversion logic in the frontend to transform CSV data back to object format
- Fixed table relationship definitions in `TableColumnMetadata`
- Improved database connection handling in tests

### How to test?

1. Create a new table with the DynamoDB backend: `createTable({ name: "Test Table", isBlank: false, databaseType: "ddb" })`
2. Create a new table with the PostgreSQL backend (default): `createTable({ name: "Test Table", isBlank: false })`
3. Verify that operations (adding/updating/deleting rows and columns) work correctly on both table types
4. Check that row data is properly displayed in the frontend despite the CSV transfer format
###  Changes

Implemented a database abstraction layer for Tiles to support both DynamoDB and PostgreSQL backends.

- Added a factory pattern with `getTableOperations()` to abstract database operations
- Updated Tiles actions (create-row, find-single-row, update-row) to use the new factory pattern
- Changed default database type from 'pg' to 'ddb' in create-table mutation
- Removed the static `getColumns` method from TableColumnMetadata in favor of using relations
- Enhanced TableMetadata to properly fetch columns with ordering
- Improved row formatting in PostgreSQL implementation
### TL;DR

Added Tiles Postgres database environment variables to ECS configuration.

### What changed?

Added five new environment variables to the ECS environment configuration:
- `TILES_POSTGRES_HOST`
- `TILES_POSTGRES_DATABASE`
- `TILES_POSTGRES_USERNAME`
- `TILES_POSTGRES_PASSWORD`
- `TILES_POSTGRES_PORT`

Each variable references corresponding parameter store values with the `plumber-<ENVIRONMENT>-tiles-rds-*` pattern.
### TL;DR

Removed the explicit database type selection when creating tables, instead using LaunchDarkly flags to determine the database type.

### What changed?

- Removed `databaseType` from the `CreateTableInput` in GraphQL schema
- Added LaunchDarkly integration to determine database type when creating tables
- Added `databaseType` field to `TableMetadata` resolver to expose the database type to clients
- Updated tests to mock LaunchDarkly flag values
- Enhanced CSV import functionality with database-specific limits:
  - Increased max file size to 5MB for PostgreSQL (vs 2MB for DynamoDB)
  - Increased chunk size to 1000 rows for PostgreSQL (vs 100 for DynamoDB)
- Added pagination support for table rows with `stringifiedCursor` parameter

### How to test?

1. Create a new table and verify it uses the database type determined by LaunchDarkly
2. Import CSV files of different sizes to verify the database-specific limits
3. Test pagination by loading large tables and checking that rows load correctly
### TL;DR

Added load testing scripts for Postgres database operations with k6 extensions.

### What changed?

- Added a `.env-example` file with Postgres connection string
- Updated the README with instructions for building k6 with extensions (postgres, dotenv, dashboard)
- Updated the k6 binary to support these extensions
- Added several new load testing scripts for Postgres operations:
  - `seed_table.js` - Creates test tables
  - `bulk_write.js` - Tests bulk insert operations
  - `bulk_read.js` - Tests bulk read operations
  - `read_action.js` - Tests single read operations
  - `write_action.js` - Tests single write operations
  - `update_action.js` - Tests update operations
  - `test.js` - Simple connection test

### How to test?

1. Copy `.env-example` to `.env` and update with your Postgres connection details
2. Build k6 with extensions using the Docker command in the README:
   ```
   docker run --rm -it -e GOOS=darwin -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \
     grafana/xk6 build \
     --with github.com/grafana/xk6-sql@latest \
     --with github.com/grafana/xk6-sql-driver-postgres@latest \
     --with github.com/grafana/xk6-dashboard@latest\
     --with github.com/szkiba/xk6-dotenv@latest
   ```
3. Run the test scripts, for example:
   ```
   ./k6 run tiles/test.js --out dashboard
   ```
# Tests for Tiles v2

## Changes

1. Added a PostgreSQL container for integration tests
2. Extending existing mutation tests to work with both DynamoDB and PostgreSQL
3. Adding unit tests for PostgreSQL table functions
4. Implementing proper database type switching in mutations
@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Jul 24, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 45b4a55 | Was this helpful? Give us feedback!

# Small tiles improvments

- Add Table icon in breadcrumb to differentiate v2 from v1 tiles
![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/ycT2Xb5nBEjN2kf2gy95/130bce7b-5cb8-4fbe-b33c-5165559a2cc7.png)
- Improve cell editing functionality:
  - Allow adding line breaks with Alt+Enter
  - Change Shift+Enter to navigate upward
  - Prevent cell editing when data is being fetched
- Fix cell selection behaviour to allow selecting substrings in cel
@pregnantboy pregnantboy marked this pull request as ready for review July 25, 2025 07:05
### TL;DR

This change addresses a compatibility issue between Tiles v1 and v2. In v1, empty cells were represented as empty strings or by omitting the key entirely, while in v2, empty cells return null values. This update ensures the application can properly handle data from both versions.
Copy link
Contributor

@kevinkim-ogp kevinkim-ogp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets go 🚀

@pregnantboy pregnantboy merged commit 7bfe323 into develop-v2 Jul 25, 2025
6 checks passed
@pregnantboy pregnantboy deleted the tiles-v2/trunk branch July 25, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants