Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
933 stars 193 forks source link

Consolidate `dbtype-commands.txt` files for easier maintainability #910

Open severussundar opened 2 years ago

severussundar commented 2 years ago

As a next step to #471, move the commands that are common to all database types to a common file.

Benefits in performing this:

  1. This ensures that changes have to be made at only one place
  2. Latest updates to config files will be reflected across all SQL database types.
Aniruddh25 commented 2 years ago

Moving this to Jan2023 - since this is cleanup and we have other higher priority items.

severussundar commented 1 year ago

Moving to March2023 as this is a refactoring effort and there are higher priority items.

seantleonard commented 6 months ago

We have scripts for each db type : mssql, mysql, pgsql, dwsql.

Completing this task requires:

The above dab cli execution step doesn't have to be tightly coupled to a database type. The config-generator.sh/ps1 files no longer need to set specific db file names like:

#Generates the config files for the selected database types.
foreach($databaseType in $databaseTypes){
    if($databaseType -eq "mssql"){
        $commandFile = "mssql-commands.txt";
        $configFile = "dab-config.MsSql.json";
    }
    elseif($databaseType -eq "mysql"){
        $commandFile = "mysql-commands.txt";
        $configFile = "dab-config.MySql.json";
    }
    elseif($databaseType -eq "postgresql"){
        $commandFile = "postgresql-commands.txt";
        $configFile = "dab-config.PostgreSql.json";
    }
    elseif($databaseType -eq "dwsql"){
        $commandFile = "dwsql-commands.txt";
        $configFile = "dab-config.DwSql.json";
    }
    else{
        $commandFile = "cosmosdb_nosql-commands.txt";
        $configFile = "dab-config.CosmosDb_NoSql.json";
    }

csproj post-build step in our pipelines only ever create one of these files to use, never all 4. So file name overlap is not expected (which is why i suspect we had code like the above in the first place).

We would only really need two lines like the following:

        # <code here to run dab init --database-type {mssql, dwsql, pgsql, mysql}>  this is the only place db type is needed. the dab init step also sets our only db specific config settings like set session context (mssql) and graphqlschema file (cosmosdb)
        # generic file names
        $commandFile = "dab-setup-commands.txt";
        $configFile = "dab-config.json";
seantleonard commented 6 months ago

Setting higher priority because this will help with local dev experience. I've dealt with how tediuous it is to troubleshoot/remember to add config automation steps to ALL automation scripts.