loopbackio / loopbackio/loopback-connector

Spike: a template implementation of index & constraint migration in SqlConnector

Open
#144 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

major spike
Dominant language
JavaScript
Stars
35
Forks
102
Avg merge
14h 26m
Merged PRs (30d)
13

Description

_This is a follow-up task for the proposal outlined in strongloop/loopback-next#2712._

The intention is to share as much of index/FK migration logic among all SQL connectors, to ensure consistent behavior. This spike will allow us to better understand the effort needed to implement migration in our SQL connectors (https://github.com/strongloop/loopback-next/issues/2332).

When working on the spike, use the existing implementation in MySQL, PostgreSQL and MSSQL connectors for inspiration. Try to preserve as much backwards compatibility as feasible. We should keep support for connector-specific behavior that's easy to implement in the shared base class. It's ok to drop support for use cases that would be difficult to preserve or that would complicate the codebase too much. Take notes about what will not work so that we can write helpful release notes and a migration guide.

The implementation needs to detect index/FK metadata not supported by SQL and report warnings to console.

## Acceptance criteria

- [ ] A draft pull request with a PoC implementation showing a template implementation of INDEX and FOREIGN KEY migration in `SqlConnector`.
- [ ] In the PoC, propose how to test this functionality in automated way in all SQL connectors. It's important to test both autoupdate (incremental changes to existing schema) and automigrate (creating new tables). Do we want to create a shared test suite in loopback-connector to be executed by all SQL connectors to verify that they are supporting all common INDEX/FK configurations?
- [ ] A draft pull request in MySQL or PostgreSQL connector leveraging the new template implementation to replace connector-specific migration.
- [ ] Create a follow-up story (or multiple stories if needed) to implement the template in production quality.
- Create follow-up tasks to leverage the new template in our SQL connectors and thus let the connectors understand the new FK/INDEX definition syntax. For each SQL connector, create a new GH issue in the connector repository. As part of each story, we need to assess backwards compatibility and compile a list of breaking changes.
- [ ] MySQL
- [ ] PostgreSQL
- [ ] MSSQL
- [ ] Oracle
- [ ] DB2
- [ ] db2iseries
- [ ] dashdb
- [ ] informix
- [ ] db2x
- [ ] Update https://github.com/strongloop/loopback-next/issues/2332 with links to newly created GH issues.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the SqlConnector implementation and compare the existing MySQL, PostgreSQL, and MSSQL migration implementations. Explore how a shared INDEX and FOREIGN KEY migration template could cover autoupdate and automigrate, including warnings for unsupported metadata. Done means a draft PoC, an automated testing proposal, a connector migration example, and documented follow-up and compatibility work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, sql
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.