Default Database Connection For Attached/Scratch .sql Files
I'm transitioning to Rider and I'm looking for a way to setup a default database connection to use for executing scratch/attached .sql files. We have a large project where all our DDL files are in source control, which are run through our custom build system for database migrations.
We have attached our file directory containing all of our .sql DDL files to our solution. It's great that we can now use the Jetbrains search anywhere since it indexed the directory of SQL.
The problem is, when we try to run the DDL file (say, an ALTER PROCEDURE), it appears Rider wants us to make a configuration for the database connection for each file. I Ctrl+Alt+F5 on file a.sql and it asks to associate it with a database connection. Then I run b.sql, and it too asks for the database connection.
Is there a way to setup a default database connection for the entire attached directory of .sql files, rather than doing it one by one? I've searched the documentation and Google'd pretty extensively and haven't been able to find anything.
Thanks,
Sam
Please sign in to leave a comment.
Hello,
Have you tried configuring DDL Data Source and DDL Mapping in your solution?
Hi Ivan, thanks for the comment. I didn't see the DDL connections on my initial searching. I have read the instructions above and have managed to setup a DDL Data Source. I've included my SQL DDL directory in that data source. I also made a DDL Mapping from the DDL Data Source to my main SQL Database data source. I refreshed the DDL Data Source and saw it populates with all my SQL files. I can now open a SQL file from the DDL Data Source, however I'm still unable to execute the SQL DDL against my SQL Server instance. Ctrl+Enter (or Execute) does nothing. Ctrl+Alt+F5 does same as before - tries to setup a configuration for each and every .sql file. What am I missing to be able to execute these DDL scripts against the SQL Server data connection from within Rider?
Thanks,
Sam
Hello Sam,
There is no direct way to execute scripts from DDL data source from in Database tool window. DDL data source view in the Database tool window serves other purposes neither than execution.
You might find the following available options helpful:
Ensure you selected data source in the right-top corner of editor:
Once it is selected:
Press the Execute button in the left-top corner:
You can create a single Run configuration to execute set of .sql files. Go to Run | Edit Configurations; Add a Database Script entry; Set Name; Set data source/schema; Add .sql files to the list below; Press Apply; So that you can use this run configuration to execute several .sql files at once:
Hope that helps. Have a nice day!