mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-14 02:33:56 -04:00
Newer migration support (#1576)
This commit is contained in:
@@ -69,7 +69,7 @@ $config['migration_auto_latest'] = FALSE;
|
||||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 20170502221500;
|
||||
$config['migration_version'] = 20170924150000;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -68,6 +68,10 @@ class Login extends CI_Controller
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// trigger any required upgrade before starting the application
|
||||
$this->load->library('migration');
|
||||
$this->migration->latest();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once("Secure_Controller.php");
|
||||
|
||||
class Migrate extends Secure_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('migrate');
|
||||
|
||||
$this->load->library('migration');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('migrate/manage');
|
||||
}
|
||||
|
||||
public function perform_migration()
|
||||
{
|
||||
if(!$this->migration->latest())
|
||||
{
|
||||
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('migrate_failed - ' . $this->migration->error_string())));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('migrate_success')));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -48,15 +48,9 @@ class Secure_Controller extends CI_Controller
|
||||
$allowed_modules = $this->Module->get_allowed_office_modules($logged_in_employee_info->person_id);
|
||||
}
|
||||
|
||||
// do not show migrate module if no migration is required
|
||||
|
||||
$this->load->library('migration');
|
||||
foreach($allowed_modules->result() as $module)
|
||||
{
|
||||
if(!$this->migration->latest() || $module->module_id != 'migrate')
|
||||
{
|
||||
$data['allowed_modules'][] = $module;
|
||||
}
|
||||
$data['allowed_modules'][] = $module;
|
||||
}
|
||||
|
||||
$data['user_info'] = $logged_in_employee_info;
|
||||
|
||||
45
application/migrations/20170501150000_upgrade_to_3_1_1.php
Normal file
45
application/migrations/20170501150000_upgrade_to_3_1_1.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Migration_Upgrade_To_3_1_1 extends CI_Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
error_log('Migrating to 3.1.1');
|
||||
|
||||
$sql = file_get_contents(APPPATH . 'migrations/sqlscripts/3.0.2_to_3.1.1.sql');
|
||||
|
||||
/*
|
||||
CI migration only allows you to run one statement at a time.
|
||||
This small script splits the statements allowing you to run them all in one go.
|
||||
*/
|
||||
|
||||
$sqls = explode(';', $sql);
|
||||
array_pop($sqls);
|
||||
|
||||
foreach($sqls as $statement)
|
||||
{
|
||||
$statment = $statement . ";";
|
||||
|
||||
if(!$this->db->simple_query($statement))
|
||||
{
|
||||
foreach($this->db->error() as $error)
|
||||
{
|
||||
error_log('error: ' . $error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_log('Migrated to 3.1.1');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -8,7 +8,6 @@ class Migration_Sales_Tax_Data extends CI_Migration
|
||||
|
||||
$this->load->library('tax_lib');
|
||||
$this->load->library('sale_lib');
|
||||
|
||||
}
|
||||
|
||||
public function up()
|
||||
|
||||
45
application/migrations/20170924150000_upgrade_to_3_2_0.php
Normal file
45
application/migrations/20170924150000_upgrade_to_3_2_0.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Migration_Upgrade_To_3_2_0 extends CI_Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
error_log('Migrating to 3.2.0');
|
||||
|
||||
$sql = file_get_contents(APPPATH . 'migrations/sqlscripts/3.1.1_to_3.2.0.sql');
|
||||
|
||||
/*
|
||||
CI migration only allows you to run one statement at a time.
|
||||
This small script splits the statements allowing you to run them all in one go.
|
||||
*/
|
||||
|
||||
$sqls = explode(';', $sql);
|
||||
array_pop($sqls);
|
||||
|
||||
foreach($sqls as $statement)
|
||||
{
|
||||
$statment = $statement . ";";
|
||||
|
||||
if(!$this->db->simple_query($statement))
|
||||
{
|
||||
foreach($this->db->error() as $error)
|
||||
{
|
||||
error_log('error: ' . $error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_log('Migrated to 3.2.0');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -94,3 +94,10 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
ALTER TABLE `ospos_items`
|
||||
DROP INDEX `item_number`,
|
||||
ADD KEY `item_number` (item_number);
|
||||
|
||||
|
||||
-- Remove Migrate module as auto migration is supported
|
||||
|
||||
DELETE FROM `ospos_modules` WHERE `ospos_modules`.`module_id` = 'migrate';
|
||||
DELETE FROM `ospos_permissions` WHERE `ospos_permissions`.`permission_id` = 'migrate';
|
||||
DELETE FROM `ospos_grants` WHERE `ospos_grants`.`permission_id` = 'migrate' AND `ospos_grants`.`person_id` = 1;
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php $this->load->view("partial/header"); ?>
|
||||
|
||||
<?php echo form_open("migrate/perform_migration/", array('id'=>'start_migration_form','method'=>'post', 'class'=>'form-horizontal')); ?>
|
||||
<fieldset>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
|
||||
<div class='col-xs-12'>
|
||||
<strong><?php echo $this->lang->line('migrate_info'); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<div class='col-xs-12'>
|
||||
<strong><?php echo $this->lang->line('migrate_backup'); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php echo form_submit(array(
|
||||
'name'=>'submit_form',
|
||||
'id'=>'submit_form',
|
||||
'value'=>$this->lang->line('migrate_start'),
|
||||
'class'=>'btn btn-primary btn-sm pull-right'));?>
|
||||
</fieldset>
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<?php $this->load->view("partial/footer"); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
//validation and submit handling
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#start_migration_form').validate({
|
||||
submitHandler: function(form) {
|
||||
$(form).ajaxSubmit({
|
||||
success: function(response) {
|
||||
$.notify(response.message, { type: response.success ? 'success' : 'danger'} );
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -366,7 +366,6 @@ INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_i
|
||||
('module_items', 'module_items_desc', 20, 'items'),
|
||||
('module_item_kits', 'module_item_kits_desc', 30, 'item_kits'),
|
||||
('module_messages', 'module_messages_desc', 100, 'messages'),
|
||||
('module_migrate', 'module_migrate_desc', 120, 'migrate'),
|
||||
('module_office', 'module_office_desc', 1, 'office'),
|
||||
('module_receivings', 'module_receivings_desc', 60, 'receivings'),
|
||||
('module_reports', 'module_reports_desc', 50, 'reports'),
|
||||
@@ -442,7 +441,6 @@ INSERT INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES
|
||||
('items', 'items'),
|
||||
('item_kits', 'item_kits'),
|
||||
('messages', 'messages'),
|
||||
('migrate', 'migrate'),
|
||||
('office', 'office'),
|
||||
('receivings', 'receivings'),
|
||||
('reports', 'reports'),
|
||||
@@ -494,7 +492,6 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`, `menu_group`) VALUES
|
||||
('items', 1, 'home'),
|
||||
('item_kits', 1, 'home'),
|
||||
('messages', 1, 'home'),
|
||||
('migrate', 1, 'office'),
|
||||
('receivings', 1, 'home'),
|
||||
('reports', 1, 'home'),
|
||||
('sales', 1, 'home'),
|
||||
|
||||
@@ -366,7 +366,6 @@ INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_i
|
||||
('module_items', 'module_items_desc', 20, 'items'),
|
||||
('module_item_kits', 'module_item_kits_desc', 30, 'item_kits'),
|
||||
('module_messages', 'module_messages_desc', 100, 'messages'),
|
||||
('module_migrate', 'module_migrate_desc', 120, 'migrate'),
|
||||
('module_office', 'module_office_desc', 1, 'office'),
|
||||
('module_receivings', 'module_receivings_desc', 60, 'receivings'),
|
||||
('module_reports', 'module_reports_desc', 50, 'reports'),
|
||||
@@ -442,7 +441,6 @@ INSERT INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES
|
||||
('items', 'items'),
|
||||
('item_kits', 'item_kits'),
|
||||
('messages', 'messages'),
|
||||
('migrate', 'migrate'),
|
||||
('office', 'office'),
|
||||
('receivings', 'receivings'),
|
||||
('reports', 'reports'),
|
||||
@@ -494,7 +492,6 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`, `menu_group`) VALUES
|
||||
('items', 1, 'home'),
|
||||
('item_kits', 1, 'home'),
|
||||
('messages', 1, 'home'),
|
||||
('migrate', 1, 'office'),
|
||||
('receivings', 1, 'home'),
|
||||
('reports', 1, 'home'),
|
||||
('sales', 1, 'home'),
|
||||
|
||||
@@ -366,7 +366,6 @@ INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_i
|
||||
('module_items', 'module_items_desc', 20, 'items'),
|
||||
('module_item_kits', 'module_item_kits_desc', 30, 'item_kits'),
|
||||
('module_messages', 'module_messages_desc', 100, 'messages'),
|
||||
('module_migrate', 'module_migrate_desc', 120, 'migrate'),
|
||||
('module_office', 'module_office_desc', 1, 'office'),
|
||||
('module_receivings', 'module_receivings_desc', 60, 'receivings'),
|
||||
('module_reports', 'module_reports_desc', 50, 'reports'),
|
||||
@@ -442,7 +441,6 @@ INSERT INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES
|
||||
('items', 'items'),
|
||||
('item_kits', 'item_kits'),
|
||||
('messages', 'messages'),
|
||||
('migrate', 'migrate'),
|
||||
('office', 'office'),
|
||||
('receivings', 'receivings'),
|
||||
('reports', 'reports'),
|
||||
@@ -494,7 +492,6 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`, `menu_group`) VALUES
|
||||
('items', 1, 'home'),
|
||||
('item_kits', 1, 'home'),
|
||||
('messages', 1, 'home'),
|
||||
('migrate', 1, 'office'),
|
||||
('receivings', 1, 'home'),
|
||||
('reports', 1, 'home'),
|
||||
('sales', 1, 'home'),
|
||||
|
||||
Reference in New Issue
Block a user