Skip to content

Preview feature feedback: microsoftSqlServer #4039

Closed

Description

@2color

Please share your feedback about the preview of Microsoft SQL Server support that was released in v2.10.0 in this issue.

  • If you encounter a bug, please open a bug report in this repo.
  • If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.

If you have any questions, don't hesitate to ask them in the #prisma-client channel in the Prisma Slack.

Related epic: #4081

Activity

  1. added
    topic: previewFeatures
    topic: sql server
    on Oct 26, 2020
  2. changed the title [-]Preview feature feedback: MSSQL (`microsoftSqlServer`) (since 2.10.0)[/-] [+]Preview feature feedback: `microsoftSqlServer`[/+] on Oct 27, 2020
  3. chuanqisun commented on Oct 27, 2020

    @chuanqisun

    Hi @2color, does this include Azure SQL? or it's just the on prem MS SQL?

  4. pimeys commented on Oct 28, 2020

    @pimeys

    Hi @chuanqisun, we do support Azure SQL due to it being SQL Server 2017 underneath. Most of our tests for now run against the dockerized versions of SQL Server 2017 and 2019, but Azure SQL is a first priority for us.

    It is very much possible we're also working just fine with versions from 2012 forward, but right now our big test suites run against versions 2017 and 2019.

  5. josh-hemphill commented on Apr 27, 2021

    @josh-hemphill

    I created a feature request separately in #6823 , but it probably relates to this.

    Even thought SQL Server doesn't support Enums, it would be really nice to still be able to write a schema with enums for the intellisense and type information etc. If I ever have to change the database provider it would also be really nice to only have to worry about native type support/conversions and not about how the schema was structured.

    Perhaps there could be some sort of flag to enforce the strong enforcement of enum support that if disabled would create a closest analog in SQL Server that at least expresses the intent of the column being an enum to those working directly with the database.

  6. luomavaltteri commented on Jun 14, 2021

    @luomavaltteri

    Howdy!
    We are using Prisma with Azure SQL in our project and it has worked well this far! 🚀

    Two things we noticed:

    • When connecting to Azure SQL, you need to escape at least the user in the connection string (because of the "@" between username and server name). Figuring out how to do that in JDBC connection strings took a bit of time (put the value in curly braces), as that wasn't needed with the SQL server we used locally for development.
    • Compared to migration scripts Entity Framework generates, Prisma's migration scripts don't wrap them in transactions or track the migration history in the scripts themselves. I'm not an expert on the topic, so I'm not sure if these things are really needed, but maybe a thing to look at? Below a sample of the EF migration script
    BEGIN TRANSACTION;
    GO
    
    <migrate stuff>
    
    INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
    VALUES (N'20XXXXXXXXXX_AddObject', N'5.0.0');
    GO
    
    COMMIT;
    GO
    

    Keep up the good work 👍

  7. pimeys commented on Jun 14, 2021

    @pimeys

    Hey @luomavaltteri,

    • Could you give an example of a connection string that works differently in SQL Server compared to Prisma?
    • Yeah, due to none of the other databases we support allow running migrations in transactions, we don't do that to SQL Server either. I'm raising up this issue in today's Migrate team meeting though.
  8. luomavaltteri commented on Jun 14, 2021

    @luomavaltteri

    So for a SQL server something like this works in the .env file:

    DATABASE_URL=sqlserver://localhost:1433;database=db;user=sa;password=veryStrongPassword;trustServerCertificate=true;
    

    But with Azure SQL escaping the user is needed (and most likely the password also). That's a JDBC connection string copied from Azure portal for the database.

    DATABASE_URL=sqlserver://<server>.database.windows.net:1433;database=db;user={user@<server>};password={<password>};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
    

    The logs prisma CLI gives is a bit odd, but seems to work:

    ❯ npx prisma migrate deploy
    Environment variables loaded from .env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": SQL Server database "undefined" at "<server>};password={<password>};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;:1433"
    
    1 migration found in prisma/migrations
    
    The following migration have been applied:
    
    migrations/
      └─ 20210614080427_init/
        └─ migration.sql
          
    All migrations have been successfully applied.
    
  9. pimeys commented on Jun 14, 2021

    @pimeys

    Checking the connection string problem right away.

    Created an issue for you for migrations wrapped in plast... transactions.
    #7641

    P.s. @luomavaltteri if you're in our public slack, send me a PM, I like to ask a few questions from our SQL Server users before GA.

  10. luomavaltteri commented on Jun 14, 2021

    @luomavaltteri

    Thanks @pimeys, I'll join your Slack 👍

  11. Jolg42 commented on Jun 15, 2021

    @Jolg42
    Contributor

    Thank you @luomavaltteri for the report.
    This full connection string (which includes password)

    Datasource "db": SQL Server database "undefined" at "};password={};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;:1433"

    This is not expected from the CLI, we make sure that only the server host and port are logged for the other connectors and it seems we forgot something for SQL Server.

    I fixed that in our dev version and will be part of 2.25.0 release.

  12. janconc commented on Jun 24, 2021

    @janconc

    Hi guys,

    Not sure if this question belongs here, but anyway:
    I am currently using TypeORM and evaluating Prisma. I have a Database in Azure/SQL Server with multiple schemas, each schema having few tables in them. Is it possible to specify for each model in Prisma schema to which DB schema it belongs? In the future I may need to write queries that SELECTs data from tables from multiple Db schemas.

    It seems that Prisma always uses the default dbo DB schema and I don't see anywhere a possibility to override it.

    Keep up the good work!

  13. pimeys commented on Jun 24, 2021

    @pimeys

    @janconc Not yet, please follow the issue for more details.

    I wrote a few proposals internally how we could do that, but there is not yet any timeframe for this.

  14. janpio commented on Jun 24, 2021

    @janpio
    Contributor

    For SQL Server the usage of "synonyms" might offer a temporary workaround as well @janconc: #1122 (comment)

  15. added this to the 2.31.0 / 3.0.x milestone on Aug 19, 2021
  16. 2color commented on Sep 7, 2021

    @2color
    ContributorAuthor

    Closing this now that this has been released to General Availability in the 3.0.1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: previewFeaturestopic: sql server

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions