Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0 Notice #139

Open
rmp135 opened this issue Mar 16, 2024 · 1 comment
Open

Version 2.0 Notice #139

rmp135 opened this issue Mar 16, 2024 · 1 comment

Comments

@rmp135
Copy link
Owner

rmp135 commented Mar 16, 2024

Hi all,

First off, sorry for the radio silence, just haven't been feeling motivated but I'm back and have been chipping away on a total overhaul.

Version 2.0 is here and there's a number of changes I'd like to go over.

  • Exports as ES module
  • Integrated testing for each DB provider using testcontainers
  • Support for MySQL enums (converts to string union)
  • Fluent API for node
  • Mapping functions for cleaner customisation
  • Modernised testing and framework using Vitest and GitHub actions

Migration Guide

Because it now exports as an ES module, consumer projects must also be of type module.

The biggest change is how the node module now works. Previously it was a couple of random functions that I never quite liked. Now, it uses a fluent API to chain operations together. See the node module docs for more details.

import { Client } from '@rmp135/sql-ts'

const config = { }

const ts = await Client
  .withConfig(config)
  .fetchDatabase()
  .mapColumn('public.users.name', ((column, table, schema) => ({ ...column, propertyName: 'newName' })))
  .toTypescript()

For CLI users, there's no specific changes required, however please report if you find anything untoward.

For those with custom templates:

  • The full config is now passed in as a parameter so the previous custom block becomes config.custom.
  • The main database object is a now an object with an array of schemas, each with a name, namespaceName and list of tables and enums.

The folder config option has been removed, just use filename with a path.

@rmp135 rmp135 pinned this issue Mar 16, 2024
@laurent22
Copy link
Contributor

laurent22 commented Oct 26, 2024

Honestly I question how useful these breaking changes are, when they were apparently done for aesthetic reasons. We're certainly not going to update if it means we have to migrate everything, especially since we gain nothing in the process.

Sometimes it's ok to stick with ugly APIs and not break everybody's build. As a dev I can understand you want to clean up your package, but it's not important to anybody else. As a user, we just want something that works and your package did that just fine.

Not to mention that you'll now get bug reports for both v1 and v2 because people will stick with the older version.

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

No branches or pull requests

2 participants