yuniql icon indicating copy to clipboard operation
yuniql copied to clipboard

Use reserved directory _create for setting up new databases

Open rdagumampan opened this issue 4 years ago • 1 comments

When -a or auto-create-db is passed during yuniql run, it will create an empty database using the default create database sql commands of the target platform. The command is typically like:

CREATE DATABASE helloyuniql;

This is not good enough when user needs special configuration of the database during creation such as specifying where the data files are, collation setup, partitions, file groups etc. To achieve this, we would need to execute SQL scripts stored on _create directory. For example:

CREATE DATABASE Music
ON
( NAME = Music_dat,  
    FILENAME = 'D:\temp\musicdat.mdf',
    SIZE = 10,
    MAXSIZE = 50,
    FILEGROWTH = 5 )  
LOG ON
( NAME = Music_log,  
    FILENAME = 'D:\temp\musiclog.ldf',
    SIZE = 5,
    MAXSIZE = 25,
    FILEGROWTH = 5 );
GO

https://www.quackit.com/sql_server/t-sql/examples/create_database.cfm

rdagumampan avatar Jan 25 '21 10:01 rdagumampan

Maybe afterall this is not needed because users can anyway place these scripts inside _init directory. The _init script files are executed only once and only when the target database is not yet created.

rdagumampan avatar Feb 06 '21 07:02 rdagumampan