Heroku DB not finding row after an edit changed the order of rows in DB - mysql

So this is interesting. I edited a user profile, and it moved in the database on heroku from what I can tell. It is now below row 15, and it has an id of 1. Here is the output from console, after connecting to the heroku db:
3 | Danyka | Jones | filip_nikolaus | pass | | https://lh3.googleusercontent.com/-jMRFTtoaM9I/U81C6LW8SMI/AAAAAAAABJU/6fI9fgRLVnQ/w426-h341/giving-hand.jpg | Add quote.. | | | 2015-09-02 05:37:35.252597 | 2015-09-02 05:37:35.252597 |
4 | Angelina | Kub | ebbarempel | pass | | http://2.bp.blogspot.com/-iaXdpAip50o/TVaA1dfkLKI/AAAAAAAAADI/Lc58jQMLQtw/s320/happy3.png | Add quote.. | | | 2015-09-02 05:37:35.258762 | 2015-09-02 05:37:35.258762 |
5 | Bo | Barton | per_hammes | pass | | http://www.theunpluggedwoodshop.com/wp-content/uploads/2012/10/giving-tree-1.jpg | Add quote.. | | | 2015-09-02 05:37:35.26435 | 2015-09-02 05:37:35.26435 |
6 | Tristian | Vandervort | ulf | pass | | http://2.bp.blogspot.com/-iaXdpAip50o/TVaA1dfkLKI/AAAAAAAAADI/Lc58jQMLQtw/s320/happy3.png | Add quote.. | | | 2015-09-02 05:37:35.269916 | 2015-09-02 05:37:35.269916 |
7 | Bert | Cartwright | annaschinner | pass | | https://lh3.googleusercontent.com/-jMRFTtoaM9I/U81C6LW8SMI/AAAAAAAABJU/6fI9fgRLVnQ/w426-h341/giving-hand.jpg | Add quote.. | | | 2015-09-02 05:37:35.275477 | 2015-09-02 05:37:35.275477 |
8 | Lina | Shanahan | martin | pass | | http://2.bp.blogspot.com/-iaXdpAip50o/TVaA1dfkLKI/AAAAAAAAADI/Lc58jQMLQtw/s320/happy3.png | Add quote.. | | | 2015-09-02 05:37:35.28096 | 2015-09-02 05:37:35.28096 |
9 | Laurel | Greenholt | hannahirthe | pass | | http://2.bp.blogspot.com/-iaXdpAip50o/TVaA1dfkLKI/AAAAAAAAADI/Lc58jQMLQtw/s320/happy3.png | Add quote.. | | | 2015-09-02 05:37:35.286482 | 2015-09-02 05:37:35.286482 |
10 | Victor | Becker | ingegerd_altenwerth | pass | | https://lh3.googleusercontent.com/-jMRFTtoaM9I/U81C6LW8SMI/AAAAAAAABJU/6fI9fgRLVnQ/w426-h341/giving-hand.jpg | Add quote.. | | | 2015-09-02 05:37:35.292822 | 2015-09-02 05:37:35.292822 |
11 | Devonte | Borer | ullabritt | pass | | http://2.bp.blogspot.com/-iaXdpAip50o/TVaA1dfkLKI/AAAAAAAAADI/Lc58jQMLQtw/s320/happy3.png | Add quote.. | | | 2015-09-02 05:37:35.298556 | 2015-09-02 05:37:35.298556 |
12 | guest | guest | guest | $2a$10$ntdETJrdzHPwqEeq2Kqeme3DeU9zzi8mlz/WIUTWGWwX2ijs5vkpO | | http://img03.deviantart.net/3e34/i/2011/227/8/c/epik_face_by_epikfaceplz-d46p2on.png | | | | 2015-09-03 14:48:22.145592 | 2015-09-03 14:49:26.494595 |
13 | Linda | Marie | lindaM | $2a$10$wOlYIjTVHkHReXMlcpHNReLM/V4tMTaItnNKhuRKgc2gVwlaA9r6e | | http://tremendouswallpapers.com/wp-content/uploads/2014/12/quaker-parrots-1920x1200.jpg | | | | 2015-09-04 18:01:33.644988 | 2015-09-10 04:28:42.886892 |
15 | Linda | Gaiud | codemom | $2a$10$J..1/Kyx3isJTkAJv11bf.5/DYQccXBonf9ji6U4v/szYE3Dfm89S | | https://www.denverlibrary.org/files/css_code.jpg | | | | 2015-09-08 01:59:28.34503 | 2015-09-10 04:31:01.938624 |
1 | admin | admin | admin | $2a$10$os7EetTB/e.Lfarbvt/BFO1SW.SDC9tkaE5zlprvsmF1BaKniSWi6 | | https://scontent-lga1-1.xx.fbcdn.net/hphotos-xfa1/v/t1.0-9/11119092_10206950218382306_4406697530463059534_n.jpg?oh=3b6578dc010d0ef918008fd5b96b2e18&oe=566808E1 | No one is useless in this world who lightens the burdens of another. \r+| | | 2015-09-02 05:37:35.146649 | 2015-09-12 02:52:15.04786 | t
| | | | | | | - Charles Dickens | | | | |
(13 rows)
For some reason when I click on that users name, instead of taking me to that profile, I get an error that the page can not be found despite it obviously existing in the DB. Here is what the url looks like when it hits that route:
https://boiling-stream-6729.herokuapp.com/users/1
the controller is pretty standard:
def show
#user = User.find(params[:id])
#allContributions = Payment.where(user_id: #user.id).to_a
#userContributions =[];
#allContributions.each{|c| #userContributions << Project.find(c.project_id)}
#allContributions
end
ANY other profile I go to, I don't have this problem, so I can only conclude it is because it has been shifted down in the db. I do not however understand what that would matter, or what I should do about it. Any input as to what is happening as well as what to do is appreciated!

You should check your heroku log first. As I can see your show method is doing a bunch of things, I am sure something is failing because it can't find some related resource. Your heroku log should tell you about that. In such cases, it's always best to check the log first to see the exact error message.

Related

How to get parent-child data in one table like pivot table in MySQL?

Hello great developers!
I have an issue related to child-parent field in MySQL. Here, I create an schema here in SQL Fiddle.
I have 2 table.
sys_user table
| username | userDisplayName | userTypeCode |
|----------|-----------------|--------------|
| adhan | Adhan | ENTL |
| aruto | Aruto | RWTL |
| berry | Berry | EDTL |
| chiira | Chiira | QCED |
sys_usertype table
| userTypeCode | userTypeName | userTypeCodeParent | userTypeLevel |
|--------------|--------------------|--------------------|---------------|
| EDTL | Editor Translator | MSTL | 2 |
| ENTL | English Translator | RWTL | 3 |
| MSTL | Translator | | 1 |
| QCED | Quality Checker | | 1 |
| RWTL | Raw Translator | MSTL | 2 |
So, I have tried this query:
SELECT usr.*,
usrty_lv1.userTypeName AS userTypeLevel1 ,
usrty_lv2.userTypeName AS userTypeLevel2,
usrty.userTypeName AS userTypeLevel3
FROM sys_user usr
LEFT JOIN sys_usertype usrty
ON usr.userTypeCode = usrty.userTypeCode
LEFT JOIN sys_usertype usrty_lv2
ON usrty.userTypeCodeParent = usrty_lv2.userTypeCode
LEFT JOIN sys_usertype usrty_lv1
ON usrty_lv2.userTypeCodeParent = usrty_lv1.userTypeCode
And the result is:
====================================================================================================
| username | userDisplayName | userTypeCode | userTypeLevel1 | userTypeLevel2 | userTypeLevel3 |
====================================================================================================
| chiira | Chiira | QCED | (null) | (null) | Quality Checker |
| adhan | Adhan | ENTL | Translator | Raw Translator | English Transl.. |
| berry | Berry | EDTL | (null) | Translator | Editor Transla.. |
| aruto | Aruto | RWTL | (null) | Translator | Raw TransLator |
====================================================================================================
My goal is produce this result:
====================================================================================================
| username | userDisplayName | userTypeCode | userTypeLevel1 | userTypeLevel2 | userTypeLevel3 |
====================================================================================================
| chiira | Chiira | QCED | Quality Chec.. | (null) | (null) |
| adhan | Adhan | ENTL | Translator | Raw Translator | English Transl.. |
| berry | Berry | EDTL | Translator | Editor Trans.. | (null) |
| aruto | Aruto | RWTL | Translator | Raw TransLator | (null) |
====================================================================================================
How to achieve that? Am I doing wrong?
I'm prefer not using CTE, because I have many data :(
Thank you so much.

Mysql table records are displayed in a crooked manner

I have created a table in MySQL but when I display the table, some records are displayed in a crooked manner.
Here's the table displayed:
select * from air_passenger_profile;
+------------+----------+------------+-----------+---------------------------------+---------------+---------------------+
| profile_id | password | first_name | last_name | address | mobile_number | email_id |
+------------+----------+------------+-----------+---------------------------------+---------------+---------------------+
| PFL001 | PFL001 | LATHA | SANKAR | 123 BROAD CROSS ST,CHENNAI-48 | 9876543210 | LATHA#GMAIL.COM |
| PFL002 | PFL002 | ARUN | PRAKASH | 768 2ND STREET,BENGALURU-20 | 8094564243 | ARUN#AOL.COM |
| PFL003 | PFL003 | AMIT | VIKARAM | 43 5TH STREET,KOCHI-84 | 9497996990 | AMIT#AOL.COM |
| PFL004 | PFL004 | AARTHI | RAMESH | 343 6TH STREET,HYDERABAD-76 | 9595652530 | AARTHI#GMAIL.COM |
| PFL005 | PFL005 | SIVA | KUMAR | 125 8TH STREET,CHENNAI-46 | 9884416986 | SIVA#GMAIL.COM |
| PFL006 | PFL006 | RAMESH | BABU | 109 2ND CROSS ST,KOCHI-12 | 9432198760 | RAMESH#GMAIL.COM |
| PFL007 | PFL007 | GAYATHRI | RAGHU | 23 2ND CROSS ST,BENGALURU-12 | 8073245678 | GAYATHRI#GMAIL.COM |
| PFL008 | PFL008 | GANESH | KANNAN | 45 3RD ST,HYDERABAD-21 | 9375237890 | GANESH#GMAIL.COM |
+------------+----------+------------+-----------+---------------------------------+---------------+---------------------+
You place it into your database with spaces. At the point where you insert your variables into the databse, you could use PHP's trim() function, or MySQL's, to store it without the spaces.
To correct your current values:
UPDATE air_passenger_profile SET first_name = TRIM(first_name), etc...

Group_Concat() is not working properly in mysql

I have three tables :
em_employee :
emp_number | emp_firstname |
+------------+---------------+
| 1 | Vikram |
| 2 | S. |
| 3 | Gopal |
| 4 | Vaishnavi |
| 5 | Srinivasan |
| 6 | Saravanan
em_project
+------------+------------------------------+
| project_id | name |
+------------+------------------------------+
| 339 | MoneyGram |
| 340 | SERVICE LINE HEAD COMPLIANCE |
| 341 | SERVICE LINE HEAD ANALYTICS |
| 342 | GSI |
| 343 | Tandem |
| 344 | Master Card |
+------------+------------------------------+
em_project_employee:
+------------+------------+
| emp_number | project_id |
+------------+------------+
| 1 | 339 |
| 2 | 340 |
| 3 | 341 |
| 4 | 342 |
| 1 | 343 |
| 6 | 344 |
| 2 | 342 |
+------------+------------+
And I want Output like :
+------------+----------------------------------+
| emp_number | name |
+------------+----------------------------------+
| 1 | MoneyGram , Tandem |
| 2 | SERVICE LINE HEAD COMPLIANCE,GSI |
| 3 | SERVICE LINE HEAD ANALYTICS |
| 4 | GSI |
| 6 | Master Card |
+------------+----------------------------------+
I have tried it with GROUP_CONCAT, but something going wrong. Please help me on this.
Try this query, it produes that output:
SELECT emp_number, GROUP_CONCAT(name) FROM em_project p
INNER JOIN em_project_employee em ON p.project_id = em.project_id
GROUP BY emp_number;
The order of the data will e slightly different from what's in your desired output. If the ordering is important.
GROUP_CONCAT(name ORDER BY p.project_id)

Nova boot error Devstack

I uploaded an image to glance, an Ubuntu server 12.04 in a vhd format and when i'm trying to boot that image with nova boot i receive this:
+-------------------------------------+--------------------------------------+
| Property | Value |
+-------------------------------------+--------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | instance-00000004 |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | PK2mwUZ7SJEH |
| config_drive | |
| created | 2012-12-19T17:21:48Z |
| flavor | m1.tiny |
| hostId | |
| id | 716c9276-648c-4f90-9e67-43b8f41feb91 |
| image | Ubuntu |
| key_name | key1 |
| metadata | {} |
| name | vm1 |
| progress | 0 |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| tenant_id | 73e54a9f1ddc46fa9bd0a99d5e2a1cda |
| updated | 2012-12-19T17:21:54Z |
| user_id | dc9c0376d5604467b3898082fd270b1c |
+-------------------------------------+--------------------------------------+
ubuntu#ubuntu:~/vmware-tools-distrib$ cd /
ubuntu#ubuntu:/$ cd /home/ubuntu/devstack/
ubuntu#ubuntu:~/devstack$ nova list
+--------------------------------------+------+--------+----------+
| ID | Name | Status | Networks |
+--------------------------------------+------+--------+----------+
| 716c9276-648c-4f90-9e67-43b8f41feb91 | vm1 | ERROR | |
| 77aa0d77-2dae-4d18-a827-f08d0fb2f71a | vm1 | ERROR | |
+--------------------------------------+------+--------+----------+
So, what may be the problem??
Thanks!
you can access the database to get the detail reason if there is no obvious information in log file, query nova.instance_faults table will give you more information about why this instance became error status.
look at the nova-network.log if there is an error which is related dhcpbridge file, add that line to nova.conf
dhcpbridge = /usr/bin/nova-dhcpbridge
hint: if there is a builted image(nova list) delete it and then restart all nova-* services

mysql compare tables

I'm stuck with some tables in mysql. Don't really know how to join the info from three tables. Very thankful if anyone could help me. Thanks.
This is what I have:
Table1.Users
+----+--------+--------------+
| id | name | lastname |
+----+--------+--------------+
| 1 | Peter | Elk |
| 2 | Amy | Lee |
| 3 | James | Ride |
| 4 | Andrea | Thompson |
+----+--------+--------------+
Table2.Projects
+-----+-------------+
| id | name |
+-----+-------------+
| 13 | Lmental |
| 26 | Comunica |
| 28 | Ecobalear |
| 49 | Puigpunyent |
+-----+-------------+
Table3.Users_Projects
+----------+-------------+
| id_users | id_projects |
+----------+-------------+
| 1 | 13 |
| 1 | 28 |
| 2 | 13 |
| 2 | 28 |
| 2 | 49 |
| 3 | 28 |
| 3 | 49 |
| 4 | 49 |
+----------+-------------+
And I would like to print something like this:
+--------+--------------+----------------------------------+
| name | lastname | project |
+--------+--------------+----------------------------------+
| Peter | Elk | Lmental,Ecobalear |
| Amy | Lee | Lmental,Ecobalear, Puigpunyent |
| James | Ride | Ecobalear,Puigounyent |
| Andrea | Thompson | Puigpunyent |
+--------+--------------+----------------------------------+
Something like...
SELECT Users.name, Users.lastname, Projects.name
FROM (Users, Projects, Users_Projects)
WHERE Users_Projects.id_users=Users.id AND Users_Projects.id_projects=Projects.id
ORDER BY ...
...will output a single user/project per line, which you'll then have to manipulate in your choosen language.
Attempting to perform the concatenation, etc. in SQL is liable to lead to a pretty horrendous query.