在产品迭代开发发布过程中,由于业务需求的增加,数据库难免会有结构调整等操作.在每个版本发布过程中怎么控制每个版本server端程
在产品迭代开发发布过程中,由于业务需求的增加,,数据库难免会有结构调整等操作.
在每个版本发布过程中怎么控制每个版本server端程序与数据库版本保持一致,以及数据库升级、回滚等操作.
本博文宅鸟将向大家推荐一款mysql数据库迁移工具mysql-php-migrations
由于具体需求不同,宅鸟根据自己公司的情况将mysql-php-migrations做了一些修改来满应用!
宅鸟修改程序后的mysql迁移程序有以下目录:
config 配置文件
dbscript sql脚本目录
lib 迁移程序类库
migrate.php 迁移命令执行入口
执行php migrate.php
可以看到如下结果
我们可以看到migrate.php有很多命令
php migrate.php add test
结果:
__ __ __ __
|\/| (_ / \| __ |__)|__||__) __ |\/|. _ _ _ |_. _ _ _
| |\/__)\_\/|__ | | || | ||(_)| (_||_|(_)| )_)
/ _/
******************************************************************** v2.0.1 ***
New migration created: file
/var/www/mysqlMigrations/dbscript/2013_12_18_14_50_45_test.php
*******************************************************************************
cd dbscript
total 16
-rw-r--r-- 1 www-data www-data 4837 Sep 29 09:21 2013_06_18_17_14_16_v1.php
-rw-r--r-- 1 www-data www-data 802 Sep 29 13:29 2013_09_29_12_00_12_v1.php
-rw-r--r-- 1 root www-data 240 Dec 18 14:50 2013_12_18_14_50_45_test.php
此时dbscript目录已经新添加一个2013_12_18_14_50_45_test.php文件,改文件格式如下:
class Migration_2013_12_18_14_50_45 extends MpmMysqliMigration
{
public function up(ExceptionalMysqli &$mysqli)
{
$mysqli->exec("DO 0");
}
public function down(ExceptionalMysqli &$mysqli)
{
$mysqli->exec("DO 0");
}
}
?>
把需要修改的数据库脚本写在up函数中:
把对应修改修改所做的回滚操作卸载down函数中
注意:在生产环境下建议只做数据库的向上变迁,不做down操作,避免用户有用数据丢失.

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于索引优化器工作原理的相关内容,其中包括了MySQL Server的组成,MySQL优化器选择索引额原理以及SQL成本分析,最后通过 select 查询总结整个查询过程,下面一起来看一下,希望对大家有帮助。

sybase是基于客户/服务器体系结构的数据库,是一个开放的、高性能的、可编程的数据库,可使用事件驱动的触发器、多线索化等来提高性能。

visual foxpro数据库文件是管理数据库对象的系统文件。在VFP中,用户数据是存放在“.DBF”表文件中;VFP的数据库文件(“.DBC”)中不存放用户数据,它只起将属于某一数据库的 数据库表与视图、连接、存储过程等关联起来的作用。

数据库系统由4个部分构成:1、数据库,是指长期存储在计算机内的,有组织,可共享的数据的集合;2、硬件,是指构成计算机系统的各种物理设备,包括存储所需的外部设备;3、软件,包括操作系统、数据库管理系统及应用程序;4、人员,包括系统分析员和数据库设计人员、应用程序员(负责编写使用数据库的应用程序)、最终用户(利用接口或查询语言访问数据库)、数据库管理员(负责数据库的总体信息控制)。

了解MySQL和PostgreSQL的数据迁移与升级策略在进行数据库迁移和升级时,选择正确的策略对于保证数据的完整性和稳定性至关重要。本文将介绍MySQL和PostgreSQL两种常见数据库的数据迁移和升级策略,并提供相关的代码示例。一、MySQL数据迁移与升级策略数据迁移策略MySQL提供了多种数据迁移方案,其中最常见的是使用mysqldump命令导出和导

数据库的“完整性”是指数据的正确性和相容性。完整性是指数据库中数据在逻辑上的一致性、正确性、有效性和相容性。完整性对于数据库系统的重要性:1、数据库完整性约束能够防止合法用户使用数据库时向数据库中添加不合语义的数据;2、合理的数据库完整性设计,能够同时兼顾数据库的完整性和系统的效能;3、完善的数据库完整性有助于尽早发现应用软件的错误。

mysql查询为什么会慢,关于这个问题,在实际开发经常会遇到,而面试中,也是个高频题。遇到这种问题,我们一般也会想到是因为索引。那除开索引之外,还有哪些因素会导致数据库查询变慢呢?

结构层次是“数据库→数据表→记录→字段”;字段构成记录,记录构成数据表,数据表构成了数据库。数据库是一个完整的数据的记录的整体,一个数据库包含0到N个表,一个表包含0到N个字段,记录是表中的行。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools
