Starting with versioning mysql schemata without overkill. Good solutions?

后端 未结 11 1743
感动是毒
感动是毒 2020-12-28 23:40

I\'ve arrived at the point where I realise that I must start versioning my database schemata and changes. I consequently read the existing posts on SO about that topic but I

11条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-28 23:56

    The main ideea is to have a folder with this structure in your project base path

    /__DB
    —-/changesets
    ——–/1123
    —-/data
    —-/tables
    

    Now who the whole thing works is that you have 3 folders: Tables Holds the table create query. I recommend using the naming “table_name.sql”.

    Data Holds the table insert data query. I recommend using the same naming “table_name.sql”. Note: Not all tables need a data file, you would only add the ones that need this initial data on project install.

    Changesets This is the main folder you will work with. This holds the change sets made to the initial structure. This holds actually folders with changesets. For example i added a folder 1123 wich will contain the modifications made in revision 1123 ( the number is from your code source control ) and may contain one or more sql files.

    I like to add them grouped into tables with the naming xx_tablename.sql - the xx is a number that tells the order they need to be runned, since sometimes you need the modification runned in a certain order.

    Note: When you modify a table, you also add those modifications to table and data files … since those are the file s that will be used to do a fresh install.

    This is the main ideea.

    for more details you could check this blog post

提交回复
热议问题