-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.1
- Loading branch information
Showing
36 changed files
with
807 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
language: php | ||
php: | ||
- "7.1" | ||
- "7.0" | ||
- "5.6" | ||
- "5.5" | ||
- "5.4" | ||
|
||
install: | ||
- composer install | ||
|
||
script: | ||
- phpunit | ||
- phpunit tests/SqliteCommandTest.php | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,11 @@ | |
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"byjg/anydataset": "2.1.*", | ||
"byjg/anydataset": "3.0.*", | ||
"byjg/uri": "1.0.*", | ||
"symfony/console": "3.1.*" | ||
}, | ||
"autoload": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- THIS IS THE BASE FILE . The version '0' | ||
-- -------------------------------------------------------- | ||
|
||
-- Create the demo table USERS and populate it | ||
|
||
create table users ( | ||
|
||
id SERIAL NOT NULL PRIMARY KEY, | ||
name varchar(50) NOT NULL, | ||
createdate VARCHAR(8) | ||
|
||
); | ||
|
||
insert into users (name, createdate) values ('John Doe', '20160110'); | ||
insert into users (name, createdate) values ('Jane Doe', '20151230'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate DOWN | ||
-- from version '1' to version '0' | ||
-- | ||
-- This is the reverse operation of the script up/00001 | ||
-- -------------------------------------------------------- | ||
|
||
ALTER TABLE users | ||
ADD COLUMN createdate_old VARCHAR(8) NULL; | ||
|
||
update users | ||
set createdate_old = TO_CHAR(createdate,'YYYYMMDD'); | ||
|
||
ALTER TABLE users | ||
DROP COLUMN createdate; | ||
|
||
ALTER TABLE users | ||
RENAME COLUMN createdate_old TO createdate; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate DOWN | ||
-- from version '2' to version '1' | ||
-- | ||
-- This is the reverse operation of the script up/00002 | ||
-- -------------------------------------------------------- | ||
|
||
drop table roles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate up | ||
-- from version '0' to version '1' | ||
-- -------------------------------------------------------- | ||
|
||
|
||
ALTER TABLE users | ||
ADD COLUMN createdate_new DATE NULL; | ||
|
||
update users | ||
set createdate_new = TO_DATE(createdate, 'YYYYMMDD'); | ||
|
||
ALTER TABLE users | ||
DROP COLUMN createdate; | ||
|
||
ALTER TABLE users | ||
RENAME COLUMN createdate_new TO createdate; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate up | ||
-- from version '1' to version '2' | ||
-- -------------------------------------------------------- | ||
|
||
create table roles | ||
( | ||
id SERIAL NOT NULL PRIMARY KEY, | ||
rolename char(1) NOT NULL, | ||
userid int not null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require __DIR__ . "/../../vendor/autoload.php"; | ||
|
||
/** | ||
* Make sure you have a database with the user 'migrateuser' and password 'migratepwd' | ||
* | ||
* This user need to have grant for DDL commands; | ||
*/ | ||
|
||
$uri = new \ByJG\Util\Uri('pgsql://postgres:password@postgres-container/migratedatabase'); | ||
|
||
$migration = new \ByJG\DbMigration\Migration($uri, __DIR__); | ||
|
||
$migration->prepareEnvironment(); | ||
|
||
$migration->reset(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- THIS IS THE BASE FILE . The version '0' | ||
-- -------------------------------------------------------- | ||
|
||
-- Create the demo table USERS and populate it | ||
|
||
create table users ( | ||
|
||
ID int IDENTITY(1,1) PRIMARY KEY, | ||
name varchar(50) NOT NULL, | ||
createdate VARCHAR(8) | ||
|
||
); | ||
|
||
insert into users (name, createdate) values ('John Doe', '20160110'); | ||
insert into users (name, createdate) values ('Jane Doe', '20151230'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate DOWN | ||
-- from version '1' to version '0' | ||
-- | ||
-- This is the reverse operation of the script up/00001 | ||
-- -------------------------------------------------------- | ||
|
||
ALTER TABLE users | ||
ADD createdate_old VARCHAR(8) NULL ; | ||
|
||
update users | ||
set createdate_old = concat(DATEPART(yyyy,createdate), | ||
RIGHT('00' + CONVERT(NVARCHAR(2), DATEPART(MONTH, createdate)), 2), | ||
RIGHT('00' + CONVERT(NVARCHAR(2), DATEPART(DAY, createdate)), 2) | ||
); | ||
|
||
ALTER TABLE users | ||
DROP COLUMN createdate; | ||
|
||
EXEC sp_RENAME 'users.createdate_old' , 'createdate', 'COLUMN' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate DOWN | ||
-- from version '2' to version '1' | ||
-- | ||
-- This is the reverse operation of the script up/00002 | ||
-- -------------------------------------------------------- | ||
|
||
drop table roles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate up | ||
-- from version '0' to version '1' | ||
-- -------------------------------------------------------- | ||
|
||
|
||
ALTER TABLE users ADD createdate_new DATE NULL; | ||
|
||
update users set createdate_new = concat( | ||
substring(createdate, 1, 4), | ||
'-', | ||
substring(createdate, 5, 2), | ||
'-', | ||
substring(createdate, 7, 2) | ||
); | ||
|
||
ALTER TABLE users DROP COLUMN createdate; | ||
|
||
EXEC SP_RENAME 'users.createdate_new' , 'createdate', 'COLUMN'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
-- -------------------------------------------------------- | ||
-- This is the script for migrate up | ||
-- from version '1' to version '2' | ||
-- -------------------------------------------------------- | ||
|
||
create table roles | ||
( | ||
ID int IDENTITY(1,1) PRIMARY KEY, | ||
rolename char(1) NOT NULL, | ||
userid int not null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require __DIR__ . "/../../vendor/autoload.php"; | ||
|
||
/** | ||
* Make sure you have a database with the user 'migrateuser' and password 'migratepwd' | ||
* | ||
* This user need to have grant for DDL commands; | ||
*/ | ||
|
||
$uri = new \ByJG\Util\Uri('dblib://sa:Pa$$word!@mssql-container/migratedatabase'); | ||
|
||
$migration = new \ByJG\DbMigration\Migration($uri, __DIR__); | ||
|
||
$migration->prepareEnvironment(); | ||
|
||
$migration->reset(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<?php | ||
|
||
require "../../vendor/autoload.php"; | ||
require __DIR__ . "/../../vendor/autoload.php"; | ||
|
||
$connection = new \ByJG\AnyDataset\ConnectionManagement('sqlite:///tmp/teste.sqlite'); | ||
$uri = new \ByJG\Util\Uri('sqlite:///tmp/teste.sqlite'); | ||
|
||
$migration = new \ByJG\DbMigration\Migration($connection, '.'); | ||
$migration = new \ByJG\DbMigration\Migration($uri, __DIR__); | ||
|
||
$migration->reset(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.