如何在GitHub上包含MySQL数据库模式?

时间:2021-06-14 12:45:18

* 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:

*和mysql - va -命令行n00b,请小心点!我一直在寻找我的问题的答案,但我只能找到关于GitHubbing MySQL转储(如:data dumps)的主题,通过GitHub进行协作,或者MySQL的“版本控制”。

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

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

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?

我想在GitHub上分享一个PHP项目,它依赖于一个MySQL数据库的存在。如果有人想要复制/利用这个项目,他们需要有这些特定的表来使脚本工作(除了一个表之外,所有的表在开始时都是空的,并且随着时间的推移,用户只能通过脚本填充这些表;非空表从一开始就包含三个值)。我们该怎么做呢,通常的做法是什么?

  • 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
  • 我是否会得到一个(完整的)我自己的db/表的转储文件,然后删除所有的数据部分(除了那个非空的表之外),将所有的自动增量设置为0,然后将这个.sql文件上传到GitHub和项目的其他部分?或
  • 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?
  • 编写(PHP)脚本(可能经验不足)的用户可以使用该脚本创建这些表,而不必使用mysqldump/命令行魔法,这是最好的/更好的实践吗?

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

如果解决方案#1是可行的,那么我是否应该包括关于如何使用这种.sql文件的进一步说明?

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!).

抱歉,如果我的问题听起来很傻,但是正如我上面所说的,我自己对使用命令行来处理mysql相关的东西并不熟悉,而且直到昨天我才使用phpMyAdmin(当我用mysqldump - yay创建我的第一个转储文件时)。

1 个解决方案

#1


6  

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

通常的做法是包含创建必要表的安装脚本,因此解决方案#2将是解决方案#2。

[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

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

#1


6  

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

通常的做法是包含创建必要表的安装脚本,因此解决方案#2将是解决方案#2。

[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

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