Currently I go into phpMyAdmin, export my database as a text file and then save it with the application files before I commit things to svn (or git). Then of course, I've got to import it to production.
目前我进入phpMyAdmin,将我的数据库导出为文本文件,然后在将其提交给svn(或git)之前将其与应用程序文件一起保存。当然,我必须将它导入生产。
Is there a better way?
有没有更好的办法?
5 个解决方案
#1
If you don't have something like rails migrate, are in java environment or anything else, check out liquibase. It's pretty cool if you need that much flexibility. We just track .sql files which setup the entire database.
如果您没有像rails迁移这样的东西,在java环境或其他任何东西,请查看liquibase。如果你需要那么大的灵活性,这很酷。我们只是跟踪设置整个数据库的.sql文件。
#2
Depends on the language you use, RoR has it built in. Currently for a project I'm doing in ASP.net MVC I have 2 files in the project in a folder: database. One file contains the structure of the database and one file some dummy variables for testing. I must say it is a cumbersome way of sharing your database since when you update something you have to let the others know they have to rerun the (updated) sql structure script.
取决于您使用的语言,RoR内置它。目前我在ASP.net MVC中进行的项目我在项目中有2个文件在一个文件夹:database。一个文件包含数据库的结构,一个文件包含一些用于测试的虚拟变量。我必须说这是一种分享数据库的繁琐方式,因为当您更新某些内容时,必须让其他人知道他们必须重新运行(更新的)sql结构脚本。
The structure script deletes tables if the exist and readds them + adds new tables.
结构脚本删除表(如果存在)并读取它们+添加新表。
Could not find a better way like db::migrate of Ruby on Rails.
无法找到像Ruby on Rails的db :: migrate更好的方法。
#3
Generally, I would create a script that is able to generate the database (i.e., all the tables, users, views, indexes, etc) and another script that populates the DB with data. Then, use DBDeploy (similar to RoRs migrations) to handle all DB modifications. Then I would create build targets for all these script in Ant, NAnt, Buildr, etc. This way everything is versioned and in text files so it works with any SCM.
通常,我会创建一个能够生成数据库的脚本(即所有表,用户,视图,索引等)和另一个用数据填充数据库的脚本。然后,使用DBDeploy(类似于RoRs迁移)来处理所有数据库修改。然后我将为Ant,NAnt,Buildr等中的所有这些脚本创建构建目标。这样一切都是版本化的文本文件,因此它适用于任何SCM。
#4
If you're looking for migrations similar to db:migrate in Rails, but you're not in rails, there are other options. There's migrate4j which is similar to db:migrate, but written in/for Java. There's also liquibase, which is very flexible and (AFAIK) language independent, but does make you write everything in XML (which is kind of the opposite of "the Rails way").
如果您正在寻找类似于Rails中的db:migrate的迁移,但您不在rails中,还有其他选项。有一个migrate4j,它类似于db:migrate,但用/写在/中。还有liquibase,它非常灵活且与(AFAIK)语言无关,但确实能让你用XML编写所有内容(这与“Rails方式”相反)。
#5
If you look at Apache ODE, they have a h2.rake task for Buildr that builds a database for testing automatically.
如果你看一下Apache ODE,他们有一个针对Buildr的h2.rake任务,它可以构建一个自动测试的数据库。
#1
If you don't have something like rails migrate, are in java environment or anything else, check out liquibase. It's pretty cool if you need that much flexibility. We just track .sql files which setup the entire database.
如果您没有像rails迁移这样的东西,在java环境或其他任何东西,请查看liquibase。如果你需要那么大的灵活性,这很酷。我们只是跟踪设置整个数据库的.sql文件。
#2
Depends on the language you use, RoR has it built in. Currently for a project I'm doing in ASP.net MVC I have 2 files in the project in a folder: database. One file contains the structure of the database and one file some dummy variables for testing. I must say it is a cumbersome way of sharing your database since when you update something you have to let the others know they have to rerun the (updated) sql structure script.
取决于您使用的语言,RoR内置它。目前我在ASP.net MVC中进行的项目我在项目中有2个文件在一个文件夹:database。一个文件包含数据库的结构,一个文件包含一些用于测试的虚拟变量。我必须说这是一种分享数据库的繁琐方式,因为当您更新某些内容时,必须让其他人知道他们必须重新运行(更新的)sql结构脚本。
The structure script deletes tables if the exist and readds them + adds new tables.
结构脚本删除表(如果存在)并读取它们+添加新表。
Could not find a better way like db::migrate of Ruby on Rails.
无法找到像Ruby on Rails的db :: migrate更好的方法。
#3
Generally, I would create a script that is able to generate the database (i.e., all the tables, users, views, indexes, etc) and another script that populates the DB with data. Then, use DBDeploy (similar to RoRs migrations) to handle all DB modifications. Then I would create build targets for all these script in Ant, NAnt, Buildr, etc. This way everything is versioned and in text files so it works with any SCM.
通常,我会创建一个能够生成数据库的脚本(即所有表,用户,视图,索引等)和另一个用数据填充数据库的脚本。然后,使用DBDeploy(类似于RoRs迁移)来处理所有数据库修改。然后我将为Ant,NAnt,Buildr等中的所有这些脚本创建构建目标。这样一切都是版本化的文本文件,因此它适用于任何SCM。
#4
If you're looking for migrations similar to db:migrate in Rails, but you're not in rails, there are other options. There's migrate4j which is similar to db:migrate, but written in/for Java. There's also liquibase, which is very flexible and (AFAIK) language independent, but does make you write everything in XML (which is kind of the opposite of "the Rails way").
如果您正在寻找类似于Rails中的db:migrate的迁移,但您不在rails中,还有其他选项。有一个migrate4j,它类似于db:migrate,但用/写在/中。还有liquibase,它非常灵活且与(AFAIK)语言无关,但确实能让你用XML编写所有内容(这与“Rails方式”相反)。
#5
If you look at Apache ODE, they have a h2.rake task for Buildr that builds a database for testing automatically.
如果你看一下Apache ODE,他们有一个针对Buildr的h2.rake任务,它可以构建一个自动测试的数据库。