Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At our company we did it this way:</p> <p>We put all tables / db objects in their own file, like <code>tbl_Foo.sql</code>. The files contain several "parts" that are delimited with</p> <pre><code>-- part: create </code></pre> <p>where <code>create</code> is just a descriptive identification for a given part, the file looks like:</p> <pre><code>-- part: create IF not exists ... CREATE TABLE tbl_Foo ... -- part: addtimestamp IF not exists ... BEGIN ALTER TABLE ... END </code></pre> <p>Then we have an xml file that references every single part that we want executed when we update database to new schema. It looks pretty much like this:</p> <pre><code>&lt;playlist&gt; &lt;classes&gt; &lt;class name="table" desc="Table creation" /&gt; &lt;class name="schema" desc="Table optimization" /&gt; &lt;/classes&gt; &lt;dbschema&gt; &lt;steps db="a_database"&gt; &lt;step file="tbl_Foo.sql" part="create" class="table" /&gt; &lt;step file="tbl_Bar.sql" part="create" class="table" /&gt; &lt;/steps&gt; &lt;steps db="a_database"&gt; &lt;step file="tbl_Foo.sql" part="addtimestamp" class="schema" /&gt; &lt;/steps&gt; &lt;/dbschema&gt; &lt;/playlist&gt; </code></pre> <p>The <code>&lt;classes/&gt;</code> part if for GUI, and <code>&lt;dbschema/&gt;</code> with <code>&lt;steps/&gt;</code> is to partition changes. The <code>&lt;step/&gt;</code>:s are executed sequentially. We have some other entities, like <code>sqlclr</code> to do different things like deploy binary files, but that's pretty much it.</p> <p>Of course we have a component that takes that playlist file and a resource / filesystem object that crossreferences the playlist and takes out wanted parts and then runs them as admin on database.</p> <p>Since the "parts" in .sql's are written so they can be executed on any version of DB, we can run all parts on every previous/older version of DB and modify it to be current. Of course there are some cases where SQL server parses column names "early" and we have to later modify part's to become <code>exec_sql</code>s, but it doesn't happen often.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload