I exported my joomla.sql file through phpMyAdmin and one of the sql statement below is not complete.
CREATE TABLE XXXX_postinstall_messages (
postinstall_message_id bigint(20) UNSIGNED NOT NULL,
extension_id bigint(20) NOT NULL DEFAULT '700' COMMENT 'FK to #__extensions',
title_key varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''COMMENT
) ;
Can someone assist to provide the full schema for this particular table?
here you'll find all joomla tables https://github.com/joomla/joomla-cms/blob/staging/installation/sql/mysql/joomla.sql
Related
In Laravel migration, all are working fine. But when I export this table and import in new db, this table shows Foreign Key constraint is incorrectly formed.
sales.sql
-- phpMyAdmin SQL Dump
-- version 4.9.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 05, 2020 at 08:19 PM
-- Server version: 10.4.8-MariaDB
-- PHP Version: 7.3.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `inventory_management`
--
-- --------------------------------------------------------
--
-- Table structure for table `sales`
--
CREATE TABLE `sales` (
`id` bigint(20) UNSIGNED NOT NULL,
`sales_no` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`reference` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`date` date NOT NULL,
`sub_total` double NOT NULL,
`discount` double NOT NULL,
`discount_type` enum('percent','amount') COLLATE utf8mb4_unicode_ci NOT NULL,
`tax` double NOT NULL,
`tax_type` enum('percent','amount') COLLATE utf8mb4_unicode_ci NOT NULL,
`grand_total` double NOT NULL,
`payment_type` enum('no-payment','partial-payment','full-payment') COLLATE utf8mb4_unicode_ci NOT NULL,
`payment_term_id` bigint(20) UNSIGNED DEFAULT NULL,
`notes` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_by` bigint(20) UNSIGNED NOT NULL,
`updated_by` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
`status` enum('paid','void','cancelled','overdue','unpaid') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`customer_id` bigint(20) UNSIGNED DEFAULT NULL,
`is_item_wise_discount` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
`is_item_wise_tax` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `sales`
--
ALTER TABLE `sales`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `sales_sales_no_unique` (`sales_no`),
ADD KEY `sales_payment_term_id_index` (`payment_term_id`),
ADD KEY `sales_created_by_index` (`created_by`),
ADD KEY `sales_updated_by_index` (`updated_by`),
ADD KEY `sales_customer_id_index` (`customer_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `sales`
--
ALTER TABLE `sales`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `sales`
--
ALTER TABLE `sales`
ADD CONSTRAINT `sales_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `sales_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `sales_payment_term_id_foreign` FOREIGN KEY (`payment_term_id`) REFERENCES `payment_terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `sales_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
But all are working fine, When I alter table and do php artisan migrate. It works. The only problem is when exporting table and importing the table in new db. Thank You in advance
are you migrating just one table or the all database? if its just one table, Make sure the other tables exist in the new database with the parent table having information that the other table depending on it needs. let me say if you are migrating sales.sql and its information depends on users say( it has a users_id), then the new database must have the users table in it. Also mind about the datatypes of the column values you are relating in both tables.
I need some help!
I have an API built in laravel 5.8, i am upgrading the platform to 6.2.
After all changes in configuration files and some scripts php, all my tests witch run the migrations on SQLite is broken.
The following error is displayed:
SQLSTATE[HY000]: General error: 1 no such collation sequence: utf8_general_ci (SQL: CREATE TABLE events (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, event VARCHAR(255) NOT NULL COLLATE BINARY, description CLOB DEFAULT NULL COLLATE BINARY, invitation CLOB DEFAULT NULL COLLATE BINARY, sale CLOB DEFAULT NULL COLLATE BINARY, information CLOB DEFAULT NULL COLLATE BINARY, city VARCHAR(255) NOT NULL COLLATE BINARY,
location VARCHAR(255) NOT NULL COLLATE BINARY, date_start DATE NOT NULL, time_start TIME NOT NULL, date_end DATE DEFAULT NULL, flyer CLOB DEFAULT NULL COLLATE BINARY, atv BOOLEAN DEFAULT '1', created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, location_map VARCHAR(255) DEFAULT NULL COLLATE utf8_general_ci --IFRAME com a localização do evento.
My intention is update to 7.x after resolve all issues on 6.2.
In the migrations, was enough to remove the collation option from the fields. Example:
Initially this way:
$table->string('field', 255)->charset('utf8')->collation('utf8_general_ci')->change();
The solution was as follows:
$table->string('field', 255)->charset('utf8')->change();
Removing this option will not force a collation not accepted by SQLite.
I'm using Spring boot, and I have to initiate two tables for testing. I'm using the schema.sql inside the resource folder. But when I'm trying to create two tables in the same script and run the app, it can't load the application context.
Here is my schema.sql which I have placed at resource folder:
CREATE TABLE JobStatus_FO
(
id int(11) NOT NULL AUTO_INCREMENT,
businessDate timestamp NOT NULL,
label varchar(50),
);
CREATE TABLE JobStatusDetails_FO
{
id int(11) NOT NULL,
name varchar(50),
};
Please find the correct scripts as
CREATE TABLE JobStatus_FO
(
id INT(11) NOT NULL AUTO_INCREMENT,
businessDate TIMESTAMP NOT NULL,
label VARCHAR(50),
KEY id(id)
);
CREATE TABLE JobStatusDetails_FO
(
id INT(11) NOT NULL,
NAME VARCHAR(50)
);
Your syntax is not correct of create table .
1) In your scripts you have used extra comma "," before closing parentheses
2) Auto increment column should be used as a key in table
3) Curly braces "{" is not used within create table.
Hope this will work in to your project.
I'm migrating a database from mySQL to Oracle SQL but I'm getting a "ORA-00907: missing right parenthesis" error when creating a table. I've tried everything I can think of but still keep getting the same error.
Create table statement:
CREATE TABLE menu
(id int(11) NOT NULL AUTO_INCREMENT,
restaurant_id varchar(30) DEFAULT NULL,
menu_name varchar(30) DEFAULT NULL,
menu_description varchar(500) DEFAULT NULL,
menu_price varchar(30) DEFAULT NULL,
quantity int(11) DEFAULT '1',
PRIMARY KEY (id))
I think the problem is with the PRIMARY KEY as it's only table with PRIMARY KEYs that I get the error on. Apologies if this is an obvious question, I'm new to Oracle SQL. Thanks in advance!
Oracle != MySQL:
CREATE TABLE menu
( id number(11,0) GENERATED AS IDENTITY, --IDENTITY <=> AUTO_INCREMENT
restaurant_id varchar2(30) DEFAULT NULL, --VARCHAR2 instead of VARCHAR
menu_name varchar2(30) DEFAULT NULL,
menu_description varchar2(500) DEFAULT NULL,
menu_price varchar2(30) DEFAULT NULL,
quantity number(11,0) DEFAULT '1', --NUMBER(11,0) instead of INT(11)
PRIMARY KEY (id)
);
I want get data from two table comments,users.
comments have hasOne relation with users
public function getUser()
{
return $this->hasOne(Users::className(), ['user_id' => 'user_id']);
}
i want get comments.comment_id,comments.comment_content,comments.user_id from comments table and uses.user_name , users.user_display_name from users table to use in gridview widget.
i use
$res = Comments::find()
->select([
'comments.comment_id',
'comments.comment_content',
'comments.user_id',
'users.user_id',
'users.user_display_name',
'users.user_name',
])
->innerJoinWith('user')
->all();
this code get comments field but i can't get users.user_name,users.user_display_name from database.
How should I do it?
note: user table in database is users but when i create model with Gii,relation method declare as getUser(), i don't know why.
update 1:
comments table:
DROP TABLE IF EXISTS `comments`;
CREATE TABLE `comments` (
`comment_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`comment_content` text NOT NULL,
`comment_approved` enum('no','yes') NOT NULL DEFAULT 'no',
`comment_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
`sms_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`comment_id`),
KEY `fk_comment_sms_id` (`sms_id`),
KEY `fk_commetn_user_id` (`user_id`),
CONSTRAINT `fk_comment_sms_id` FOREIGN KEY (`sms_id`) REFERENCES `sms` (`sms_id`),
CONSTRAINT `fk_commetn_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;
users table:
CREATE TABLE `users` (
`user_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_name` varchar(60) NOT NULL DEFAULT '',
`user_pass` varchar(64) NOT NULL DEFAULT '',
`user_level` int(11) NOT NULL DEFAULT '1',
`user_email` varchar(100) NOT NULL DEFAULT '',
`user_display_name` varchar(250) NOT NULL DEFAULT '',
`user_phone_number` varchar(11) NOT NULL,
`user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`user_activation_key` varchar(60) NOT NULL,
`user_status` enum('active','deactive','delete') NOT NULL DEFAULT 'deactive',
PRIMARY KEY (`user_id`),
UNIQUE KEY `u_user_sign` (`user_name`) USING BTREE,
UNIQUE KEY `u_user_email` (`user_email`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
Not sure how you're displaying or testing if the query returned any data but you should read up on relations in Yii.
Working with Relational Data
Lazy and Eager Loading
With lazy loading the data doesn't exist until you try to access it so may not appear in things like print_r or var_dump
I recommend renaming your tables to comment and user. Read here: Table Naming Dilemma: Singular vs. Plural Names why you should use singular names.
The reason Gii generates getUser and not getUsers is because of the hasOne relationship. It's getting one -user- and not multiple -users-
Are you sure the relationship definition is correct? Is user_id the PK in the users table and the FK in the comments table? And are you sure there is correct data in the DB?