Skip to content

Commit

Permalink
Merge branch 'bug/sqlite'
Browse files Browse the repository at this point in the history
  • Loading branch information
lastlink committed Feb 21, 2018
2 parents 1144496 + 103e49b commit 36948c1
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 9 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 0.2.3-alpha

Bug fixes:

* fixed order column bug for sqlite

Version 0.2.2-alpha

New features:
Expand Down
4 changes: 4 additions & 0 deletions Controller/WikiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class WikiController extends BaseController
*/
public function show()
{
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$project = $this->getProject();

$this->response->html($this->helper->layout->project('wiki:wiki/show', array(
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugin=Wiki
version=0.2.2
version=0.2.3
all:
@ echo "Build archive for plugin ${plugin} version=${version}"
@ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip
8 changes: 4 additions & 4 deletions Model/Wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getWikipages($project_id)
self::WIKITABLE . '.content',
self::WIKITABLE . '.project_id',
self::WIKITABLE . '.is_active',
self::WIKITABLE . '.order',
self::WIKITABLE . '.ordercolumn',
self::WIKITABLE . '.creator_id',
self::WIKITABLE . '.date_creation',
self::WIKITABLE . '.date_modification',
Expand All @@ -78,7 +78,7 @@ public function getWikipages($project_id)
->left(UserModel::TABLE, 'c', 'id', self::WIKITABLE, 'creator_id')
->left(UserModel::TABLE, 'mod', 'id', self::WIKITABLE, 'modifier_id')
->eq('project_id', $project_id)
->asc('order')->findAll();
->asc('ordercolumn')->findAll();

// return $this->db->table(self::TABLE)
// ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name')
Expand Down Expand Up @@ -110,7 +110,7 @@ public function getWikipage($wiki_id)
self::WIKITABLE . '.title',
self::WIKITABLE . '.content',
self::WIKITABLE . '.project_id',
self::WIKITABLE . '.order',
self::WIKITABLE . '.ordercolumn',
self::WIKITABLE . '.is_active',
self::WIKITABLE . '.creator_id',
self::WIKITABLE . '.date_creation',
Expand Down Expand Up @@ -202,7 +202,7 @@ public function createpage($project_id, $title, $content, $date = '', $order = n
'title' => $title,
'content' => $content,
'date_creation' => $date ?: date('Y-m-d'),
'order' => $order ?: time(),
'ordercolumn' => $order ?: time(),
);
$this->prepare($values);

Expand Down
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '0.2.2';
return '0.2.3';
}

public function getPluginHomepage()
Expand Down
7 changes: 6 additions & 1 deletion Schema/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

use PDO;

const VERSION = 5;
const VERSION = 6;

function version_6(PDO $pdo){
// insert persistEditions into settings
$pdo->exec("ALTER TABLE `wikipage` CHANGE COLUMN `order` `ordercolumn` int(11) NOT NULL;");
}

function version_5(PDO $pdo){
// insert persistEditions into settings
Expand Down
8 changes: 7 additions & 1 deletion Schema/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

use PDO;

const VERSION = 1;
const VERSION = 2;

function version_2(PDO $pdo)
{
$pdo->exec('ALTER TABLE wikipage RENAME COLUMN "order" TO "ordercolumn"');

}

function version_1(PDO $pdo)
{
Expand Down
45 changes: 44 additions & 1 deletion Schema/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,50 @@

use PDO;

const VERSION = 1;
const VERSION = 2;

function version_2(PDO $pdo)
{

// drop all tables
$pdo->exec('drop table wikipage; drop table wikipage_has_files; drop table wikipage_editions; ');

$pdo->exec("CREATE TABLE `wikipage` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`project_id` INTEGER NOT NULL,
`title` varchar(255) NOT NULL,
`content` TEXT DEFAULT 1,
`is_active` int(4) DEFAULT 1,
`creator_id` int(11) DEFAULT 0,
`modifier_id` int(11),
`date_creation` INTEGER,
`date_modification` INTEGER,
`ordercolumn` INTEGER DEFAULT 1,
`editions` INTEGER DEFAULT 1,
`current_edition` INTEGER DEFAULT 1,
FOREIGN KEY(`project_id`) REFERENCES `projects`(`id`)
);");

$pdo->exec('CREATE TABLE wikipage_has_files (
"id" INTEGER PRIMARY KEY,
name VARCHAR(50),
path VARCHAR(255),
is_image INTEGER DEFAULT 0,
wikipage_id INT,
FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE
)');

$pdo->exec('CREATE TABLE wikipage_editions (
`edition` INT NOT NULL,
`title` varchar(255) NOT NULL,
`content` TEXT,
`creator_id` int(11) DEFAULT 0,
`date_creation` VARCHAR(10) DEFAULT NULL,
wikipage_id INT NOT NULL,
PRIMARY KEY (`edition`,`wikipage_id`),
FOREIGN KEY(wikipage_id) REFERENCES wikipage(id) ON DELETE CASCADE
)');
}

function version_1(PDO $pdo)
{
Expand Down

0 comments on commit 36948c1

Please sign in to comment.