如何在GitHub上包含MySQL数据库模式? [英] How to include MySQL database schema on GitHub?

查看:448
本文介绍了如何在GitHub上包含MySQL数据库模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,Stackoverflow和MySQL-via-command-line n00b,请温柔!我一直在四处寻找我的问题的答案,但只能通过GitHub查找与GitHubbing MySQL转储(如:数据转储)中的协作或MySQL版本控制相关的主题,这两者都不告诉我我想知道什么:

如何在GitHub上包含MySQL数据库模式/关于PHP项目表的信息?



我想在GitHub上共享一个PHP项目,该项目依赖于某些表的MySQL数据库的存在。如果有人想要复制/使用这个项目,他们需要使用这些特定的表格来使脚本正常工作(除了一个表格之外,其他表格在开始时都是空的,并且只能由用户通过脚本随时填充;非空表从一开始就包含三个值)。如何做到这一点,什么是常规做法




  • 我会得到一个(完整)转储然后
    删除所有数据部分(除了那个非空的
    表),将所有自动增量设置为零,然后将.sql文件
    上传到GitHub以及其他项目?
    OR

  • 编写一个(PHP)脚本的最佳/最佳做法是使用
    (可能没有那么经验)用户可以创建这些表而不需要
    必须使用mysqldump /命令行魔术?


    如果解决方案#1是如何使用这样的.sql文件?



    对不起,如果我的问题听起来很愚蠢,但正如我上面所说,我自己是新的使用MySQL命令行相关的东西,并且直到昨天才使用phpMyAdmin(当我使用mysqldump创建了我的第一个转储文件--yay!)。

    解决方案通常的做法是包含一个安装脚本来创建必要的表格,因此解决方案#2将成为一种方式。



    该脚本可能只是重播转储。 ;)



    您也许对迁移感兴趣:如何为PHP / MySQL应用程序自动迁移(模式和数据)


    Stackoverflow and MySQL-via-command-line n00b here, please be gentle! I've been looking around for answers to my question but could only find topics dealing with GitHubbing MySQL dumps (as in: data dumps) for collaboration or MySQL "version control" via GitHub, neither of which tells me what I want to know:

    How does one include MySQL database schemas/information on tables with PHP projects on GitHub?

    I want to share a PHP project on GitHub which relies on the existence of a MySQL database with certain tables. If someone wanted to copy/make use of this project, they would need to have these particular tables in place to make the script work (all tables but one are empty in the beginning and only get filled by the user over time, via the script; the non-empty table holds three values from the start). How does one go about this, what is common practice?

    • Would I just get a (complete) dump file of my own db/tables, then delete all the data parts (except for that one non-empty table), set all autoincrements to zero and then upload that .sql file to GitHub along with the rest of the project? OR
    • Is it best/better practice to write a (PHP) script with which the (maybe not-so-experienced) user can create these tables without having to use mysqldump/command line magic?

    If solution #1 is the way to go, would I include further instructions on how to use such a .sql file?

    Sorry if my questions sound silly, but as I said above, I myself am new to using the command line for MySQL-related things and had only ever used phpMyAdmin until yesterday (when I created my very first dump file with mysqldump - yay!).

    解决方案

    Common practice is to include an install script that creates the necessary tables, so solution #2 would be the way to go.

    [edit] That script could ofc just replay a dump. ;)

    You might also be interested in migrations: How to automate migration (schema and data) for PHP/MySQL application

    这篇关于如何在GitHub上包含MySQL数据库模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆