Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Goodbye database prefix #340
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Janssens committed Apr 2, 2013
1 parent 1f9904b commit cfa734e
Show file tree
Hide file tree
Showing 33 changed files with 601 additions and 719 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ protected function _initialize(Library\Config $config)
'username' => $application->getCfg('user'),
'password' => $application->getCfg('password'),
'database' => $application->getCfg('db'),
),
'table_prefix' => $application->getCfg('dbprefix')
)
));

parent::_initialize($config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ protected function _initialize(Library\Config $config)
'username' => $application->getCfg('user'),
'password' => $application->getCfg('password'),
'database' => $application->getCfg('db'),
),
'table_prefix' => $application->getCfg('dbprefix')
)
));

parent::_initialize($config);
Expand Down
4 changes: 2 additions & 2 deletions component/activities/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- --------------------------------------------------------
--
-- Table structure for table `#__activities`
-- Table structure for table `activities`
--

CREATE TABLE `#__activities` (
CREATE TABLE `activities` (
`activities_activity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uuid` VARCHAR(36) NOT NULL DEFAULT '' UNIQUE,
`application` VARCHAR(10) NOT NULL DEFAULT '',
Expand Down
4 changes: 2 additions & 2 deletions component/articles/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- --------------------------------------------------------
--
-- Table structure for table `#__articles`
-- Table structure for table `articles`
--

CREATE TABLE `#__articles` (
CREATE TABLE `articles` (
`articles_article_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`slug` varchar(255) DEFAULT NULL,
Expand Down
10 changes: 5 additions & 5 deletions component/attachments/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- --------------------------------------------------------
--
-- Table structure for table `#__attachments`
-- Table structure for table `attachments`
--

CREATE TABLE `#__attachments` (
CREATE TABLE `attachments` (
`attachments_attachment_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`container` varchar(255) NOT NULL,
Expand All @@ -22,13 +22,13 @@ CREATE TABLE `#__attachments` (

-- --------------------------------------------------------
--
-- Table structure for table `#__attachments_relations`
-- Table structure for table `attachments_relations`
--

CREATE TABLE `#__attachments_relations` (
CREATE TABLE `attachments_relations` (
`attachments_attachment_id` int(10) unsigned NOT NULL,
`table` varchar(64) NOT NULL,
`row` int(10) unsigned NOT NULL,
KEY `attachments_attachment_id` (`attachments_attachment_id`),
CONSTRAINT `#__attachments_relations_ibfk_1` FOREIGN KEY (`attachments_attachment_id`) REFERENCES `#__attachments_attachments` (`attachments_attachment_id`) ON DELETE CASCADE
CONSTRAINT `attachments_relations_ibfk_1` FOREIGN KEY (`attachments_attachment_id`) REFERENCES `attachments_attachments` (`attachments_attachment_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4 changes: 2 additions & 2 deletions component/categories/resources/install/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- --------------------------------------------------------

--
-- Table structure for table `#__categories`
-- Table structure for table `categories`
--

CREATE TABLE `#__categories` (
CREATE TABLE `categories` (
`categories_category_id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL DEFAULT '',
Expand Down
4 changes: 2 additions & 2 deletions component/comments/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- --------------------------------------------------------
--
-- Table structure for table `#__comments`
-- Table structure for table `comments`
--

CREATE TABLE `#__comments` (
CREATE TABLE `comments` (
`comments_comment_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`table` VARCHAR(64) NOT NULL,
`row` INT UNSIGNED NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions component/contacts/resources/install/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- --------------------------------------------------------

--
-- Table structure for table `#__contacts`
-- Table structure for table `contacts`
--

CREATE TABLE `#__contacts` (
CREATE TABLE `contacts` (
`contacts_contact_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`slug` varchar(255) DEFAULT NULL,
Expand Down
4 changes: 2 additions & 2 deletions component/extensions/resources/install/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- --------------------------------------------------------

--
-- Table structure for table `#__extensions_components`
-- Table structure for table `extensions_components`
--

CREATE TABLE `#__extensions_components` (
CREATE TABLE `extensions_components` (
`extensions_component_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(50) NOT NULL DEFAULT '',
`name` varchar(50) NOT NULL DEFAULT '',
Expand Down
10 changes: 5 additions & 5 deletions component/files/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--
-- Table structure for table `#__files_containers`
-- Table structure for table `files_containers`
--

CREATE TABLE `#__files_containers` (
CREATE TABLE `files_containers` (
`files_container_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`slug` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
Expand All @@ -15,10 +15,10 @@ CREATE TABLE `#__files_containers` (
-- --------------------------------------------------------

--
-- Table structure for table `#__files_thumbnails`
-- Table structure for table `files_thumbnails`
--

CREATE TABLE `#__files_thumbnails` (
CREATE TABLE `files_thumbnails` (
`files_thumbnail_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`files_container_id` varchar(255) NOT NULL,
`folder` varchar(255) NOT NULL,
Expand All @@ -27,5 +27,5 @@ CREATE TABLE `#__files_thumbnails` (
PRIMARY KEY (`files_thumbnail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT IGNORE INTO `#__files_containers` (`files_container_id`, `slug`, `title`, `path`, `parameters`) VALUES
INSERT IGNORE INTO `files_containers` (`files_container_id`, `slug`, `title`, `path`, `parameters`) VALUES
(NULL, 'files-files', 'Images', 'images', '{"thumbnails": true,"maximum_size":"10485760","allowed_extensions": ["bmp", "csv", "doc", "gif", "ico", "jpg", "jpeg", "odg", "odp", "ods", "odt", "pdf", "png", "ppt", "swf", "txt", "xcf", "xls"],"allowed_mimetypes": ["image/jpeg", "image/gif", "image/png", "image/bmp", "application/x-shockwave-flash", "application/msword", "application/excel", "application/pdf", "application/powerpoint", "text/plain", "application/x-zip"]}');
2 changes: 1 addition & 1 deletion component/languages/database/behavior/translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected function _afterTableUpdate(Library\CommandContext $context)

foreach($translations as $translation)
{
$prefix = $database->getTablePrefix().($translation->iso_code != $primary->iso_code ? strtolower($translation->iso_code.'_') : '');
$prefix = $translation->iso_code != $primary->iso_code ? strtolower($translation->iso_code.'_') : '';
$query = 'REPLACE INTO '.$database->quoteIdentifier($prefix.$table->name).' '.$select;
$database->execute($query);
}
Expand Down
3 changes: 1 addition & 2 deletions component/languages/database/row/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ public function save()
{
$tables = $this->getService('com:languages.model.tables')->getRowset();
$database = $this->getTable()->getAdapter();
$prefix = $database->getTablePrefix();

foreach($tables as $table)
{
$table_name = strtolower($this->iso_code).'_'.$table->name;

// Add language specific table and copy the content of the original table.
$database->execute('CREATE TABLE '.$database->quoteIdentifier($prefix.$table_name).' LIKE '.$database->quoteIdentifier($prefix.$table->name));
$database->execute('CREATE TABLE '.$database->quoteIdentifier($table_name).' LIKE '.$database->quoteIdentifier($table->name));

$select = $this->getService('lib:database.query.select')
->table($table->name);
Expand Down
5 changes: 2 additions & 3 deletions component/languages/database/row/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function save()
if($this->getStatus() == Library\Database::STATUS_UPDATED && $modified && $this->enabled)
{
$database = $this->getTable()->getAdapter();
$prefix = $database->getTablePrefix();
$languages = $this->getService('application.languages');
$primary = $languages->getPrimary();

Expand All @@ -38,8 +37,8 @@ public function save()
$table = strtolower($language->iso_code).'_'.$this->name;

// Create language specific table.
$query = 'CREATE TABLE '.$database->quoteIdentifier($prefix.$table).
' LIKE '.$database->quoteIdentifier($prefix.$this->name);
$query = 'CREATE TABLE '.$database->quoteIdentifier($table).
' LIKE '.$database->quoteIdentifier($this->name);
$database->execute($query);

// Copy content of original table into the language specific one.
Expand Down
14 changes: 7 additions & 7 deletions component/languages/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- --------------------------------------------------------
--
-- Table structure for table `#__languages`
-- Table structure for table `languages`
--

CREATE TABLE `#__languages` (
CREATE TABLE `languages` (
`languages_language_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`application` VARCHAR(50) NOT NULL,
`name` VARCHAR(150) NOT NULL,
Expand All @@ -19,10 +19,10 @@ CREATE TABLE `#__languages` (
-- --------------------------------------------------------

--
-- Table structure for table `#__languages_translations`
-- Table structure for table `languages_translations`
--

CREATE TABLE `#__languages_translations` (
CREATE TABLE `languages_translations` (
`languages_translation_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`iso_code` VARCHAR(8) NOT NULL,
`table` VARCHAR(64) NOT NULL,
Expand All @@ -37,15 +37,15 @@ CREATE TABLE `#__languages_translations` (
-- --------------------------------------------------------

--
-- Table structure for table `#__languages_tables`
-- Table structure for table `languages_tables`
--

CREATE TABLE `#__languages_tables` (
CREATE TABLE `languages_tables` (
`languages_table_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`extensions_component_id` INT(11) UNSIGNED,
`name` VARCHAR(64) NOT NULL,
`unique_column` VARCHAR(64) NOT NULL,
`enabled` BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY (`languages_table_id`),
CONSTRAINT `#__languages_tables__extensions_component_id` FOREIGN KEY (`extensions_component_id`) REFERENCES `#__extensions_components` (`extensions_component_id`) ON DELETE CASCADE
CONSTRAINT `languages_tables__extensions_component_id` FOREIGN KEY (`extensions_component_id`) REFERENCES `extensions_components` (`extensions_component_id`) ON DELETE CASCADE
) ENGINE=InnoDB CHARSET=utf8;
34 changes: 17 additions & 17 deletions component/pages/resources/install/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- --------------------------------------------------------

--
-- Table structure for table `#__pages`
-- Table structure for table `pages`
--

CREATE TABLE `#__pages` (
CREATE TABLE `pages` (
`pages_page_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`pages_menu_id` INT UNSIGNED NOT NULL,
`users_group_id` INT UNSIGNED NOT NULL,
Expand All @@ -26,8 +26,8 @@ CREATE TABLE `#__pages` (
`access` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`params` TEXT,
PRIMARY KEY (`pages_page_id`),
CONSTRAINT `#__pages__pages_menu_id` FOREIGN KEY (`pages_menu_id`) REFERENCES `#__pages_menus` (`pages_menu_id`) ON DELETE CASCADE,
CONSTRAINT `#__pages__link_id` FOREIGN KEY (`link_id`) REFERENCES `#__pages` (`pages_page_id`) ON DELETE CASCADE,
CONSTRAINT `pages__pages_menu_id` FOREIGN KEY (`pages_menu_id`) REFERENCES `pages_menus` (`pages_menu_id`) ON DELETE CASCADE,
CONSTRAINT `pages__link_id` FOREIGN KEY (`link_id`) REFERENCES `pages` (`pages_page_id`) ON DELETE CASCADE,
INDEX `ix_published` (`published`),
INDEX `ix_extensions_component_id` (`extensions_component_id`),
INDEX `ix_home` (`home`)
Expand All @@ -36,43 +36,43 @@ CREATE TABLE `#__pages` (
-- --------------------------------------------------------

--
-- Table structure for table `#__pages_orderings`
-- Table structure for table `pages_orderings`
--

CREATE TABLE `#__pages_orderings` (
CREATE TABLE `pages_orderings` (
`pages_page_id` int(11) unsigned NOT NULL,
`title` int(11) unsigned zerofill NOT NULL DEFAULT '00000000000',
`custom` int(11) unsigned zerofill NOT NULL DEFAULT '00000000000',
PRIMARY KEY (`pages_page_id`),
KEY `ix_title` (`title`),
KEY `ix_custom` (`custom`),
CONSTRAINT `#__pages_orderings__pages_page_id` FOREIGN KEY (`pages_page_id`) REFERENCES `#__pages` (`pages_page_id`) ON DELETE CASCADE
CONSTRAINT `pages_orderings__pages_page_id` FOREIGN KEY (`pages_page_id`) REFERENCES `pages` (`pages_page_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `#__pages_closures`
-- Table structure for table `pages_closures`
--

CREATE TABLE `#__pages_closures` (
CREATE TABLE `pages_closures` (
`ancestor_id` INT UNSIGNED NOT NULL,
`descendant_id` INT UNSIGNED NOT NULL,
`level` TINYINT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`ancestor_id`, `descendant_id`),
CONSTRAINT `#__pages_closures__ancestor_id` FOREIGN KEY (`ancestor_id`) REFERENCES `#__pages` (`pages_page_id`) ON DELETE CASCADE,
CONSTRAINT `#__pages_closures__descendant_id` FOREIGN KEY (`descendant_id`) REFERENCES `#__pages` (`pages_page_id`) ON DELETE CASCADE,
CONSTRAINT `pages_closures__ancestor_id` FOREIGN KEY (`ancestor_id`) REFERENCES `pages` (`pages_page_id`) ON DELETE CASCADE,
CONSTRAINT `pages_closures__descendant_id` FOREIGN KEY (`descendant_id`) REFERENCES `pages` (`pages_page_id`) ON DELETE CASCADE,
INDEX `ix_level` (`level`),
INDEX `ix_descendant_id` (`descendant_id`)
) ENGINE=InnoDB CHARSET = utf8;

-- --------------------------------------------------------

--
-- Table structure for table `#__pages_menus`
-- Table structure for table `pages_menus`
--

CREATE TABLE `#__pages_menus` (
CREATE TABLE `pages_menus` (
`pages_menu_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`application` varchar(50) NOT NULL,
`title` varchar(255) NOT NULL,
Expand All @@ -91,10 +91,10 @@ CREATE TABLE `#__pages_menus` (
-- --------------------------------------------------------

--
-- Table structure for table `#__pages_modules`
-- Table structure for table `pages_modules`
--

CREATE TABLE `#__pages_modules_pages` (
CREATE TABLE `pages_modules_pages` (
`pages_module_id` INT NOT NULL,
`pages_page_id` INT NOT NULL,
PRIMARY KEY (`pages_module_id`,`pages_page_id`),
Expand All @@ -104,10 +104,10 @@ CREATE TABLE `#__pages_modules_pages` (
-- --------------------------------------------------------

--
-- Table structure for table `#__pages_modules`
-- Table structure for table `pages_modules`
--

CREATE TABLE `#__pages_modules` (
CREATE TABLE `pages_modules` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`content` text NOT NULL,
Expand Down
8 changes: 4 additions & 4 deletions component/terms/resources/install/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- --------------------------------------------------------

--
-- Table structure for table `#__terms`
-- Table structure for table `terms`
--

CREATE TABLE `#__terms` (
CREATE TABLE `terms` (
`terms_term_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
Expand All @@ -26,10 +26,10 @@ CREATE TABLE `#__terms` (
-- --------------------------------------------------------

--
-- Table structure for table `#__terms_relations`
-- Table structure for table `terms_relations`
--

CREATE TABLE IF NOT EXISTS `#__terms_relations` (
CREATE TABLE IF NOT EXISTS `terms_relations` (
`terms_term_id` BIGINT(20) UNSIGNED NOT NULL,
`row` BIGINT(20) UNSIGNED NOT NULL,
`table` VARCHAR( 255 ) NOT NULL,
Expand Down
Loading

0 comments on commit cfa734e

Please sign in to comment.