monicahq / monica

Personal CRM. Remember everything about your friends, family and business relationships.
https://beta.monicahq.com
GNU Affero General Public License v3.0
21.72k stars 2.18k forks source link

Monica 2.12.0/ new installation: setup:production results in MySQL error SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd02d7d75.monica_accounts' doesn't exist (SQL: select count(*) as aggregate from `monica_accounts`) #2454

Closed Connor0308 closed 5 years ago

Connor0308 commented 5 years ago

Dear,

I am trying to get Monica working on a shared hosting with SSH access. Since any installation step went smoothly, I do not believe that the hostind environment should be any issue.

After I wanted to populate the database (using php artisan setup:production) only two tables are created in the database, running on MySQL 5.7.21. Furthermore, it throws the following errors:

ssh-w01923b8@dd6006:/www/htdocs/w01923b8/monica.test101180.test-account.com/monica$ php artisan setup:production

You are about to setup and configure Monica. Do you wish to continue? (yes/no) [no]:

yes


Welcome to Monica v2.12.0

In Connection.php line 664:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd02d7d75.monica_accounts' doesn't exist (SQL: select count(*) as aggregate from monica_accounts)

In PDOConnection.php line 63:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd02d7d75.monica_accounts' doesn't exist

In PDOConnection.php line 61:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd02d7d75.monica_accounts' doesn't exist

The migration script also errors with

ssh-w01923b8@dd6006:/www/htdocs/w01923b8/monica.test101180.test-account.com/monica$ php artisan migrate Migrating: 2014_10_12_000000_create_users_table

In Connection.php line 664:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'monica_users' already exists (SQL: create table monica_users (id int unsigned not null au
to_increment primary key, first_name varchar(255) not null, last_name varchar(255) not null, gender enum('male', 'female') not null, email varchar(25
5) not null, password varchar(255) not null, remember_token varchar(100) null, created_at timestamp null, updated_at timestamp null) default characte
r set utf8mb4 collate 'utf8mb4_unicode_ci')

In PDOStatement.php line 119:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'monica_users' already exists

In PDOStatement.php line 117:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'monica_users' already exists

The corresponding .env file looks like this:

# Welcome, friend ❤. Thanks for trying out Monica. We hope you'll have fun.
#

# Two choices: local|production. Use local if you want to install Monica as a
# development version. Use production otherwise.
APP_ENV=local

# true if you want to show debug information on errors. For production, put this
# to false.
APP_DEBUG=false

# The encryption key. This is the most important part of the application. Keep
# this secure otherwise, everyone will be able to access your application.
# Must be 32 characters long exactly.
# Use `php artisan key:generate` to generate a random key.
APP_KEY=ChangeMeBy32KeyLengthOrGenerated

# Prevent information leakage by referring to IDs with hashIds instead of
# the actual IDs used in the database.
HASH_SALT=ChangeMeBy20+KeyLength
HASH_LENGTH=18

# The URL of your application.
APP_URL=http://localhost

# Database information
# To keep this information secure, we urge you to change the default password
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
# You can use mysql unix socket if available, it overrides DB_HOST and DB_PORT values.
#DB_UNIX_SOCKET=/var/run/mysqld/mysqld.sock
DB_DATABASE=d02d7d75
DB_USERNAME=d02d7d75
DB_PASSWORD=unbelievablestrongpassword
DB_PREFIX=monica_
DB_TEST_HOST=127.0.0.1
DB_TEST_DATABASE=monica_test
DB_TEST_USERNAME=homestead
DB_TEST_PASSWORD=secret

# Use utf8mb4 database charset format to support emoji characters
# ⚠ be sure your DBMS supports utf8mb4 format
DB_USE_UTF8MB4=true

# Mail credentials used to send emails from the application.
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
# Outgoing emails will be sent with these identity
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="Monica instance"
# New registration notification sent to this email
APP_EMAIL_NEW_USERS_NOTIFICATION=

# Default locale used in the application.
APP_DEFAULT_LOCALE=en

# Ability to disable signups on your instance.
# Can be true or false. Default to false.
APP_DISABLE_SIGNUP=true

# Enable user email verification.
APP_SIGNUP_DOUBLE_OPTIN=false

# Set trusted proxy IP addresses.
# To trust all proxies that connect directly to your server, use a "*".
# To trust one or more specific proxies that connect directly to your server, use a comma separated list of IP addresses.
APP_TRUSTED_PROXIES=

# Enable automatic cloudflare trusted proxy discover
APP_TRUSTED_CLOUDFLARE=false

# Frequency of creation of new log files. Logs are written when an error occurs.
# Refer to config/logging.php for the possible values.
LOG_CHANNEL=daily

# Error tracking. Specific to hosted version on .com. You probably don't need
# those.
SENTRY_SUPPORT=false
SENTRY_LARAVEL_DSN=

# Send a daily ping to https://version.monicahq.com to check if a new version
# is available. When a new version is detected, you will have a message in the
# UI, as well as the release notes for the new changes. Can be true or false.
# Default to true.
CHECK_VERSION=true

# Change this only if you know what you are doing
CACHE_DRIVER=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

# Maximum allowed size for uploaded files, in kilobytes.
# Make sure this is an integer, without commas or spaces.
DEFAULT_MAX_UPLOAD_SIZE=10240

# Maximum allowed storage size per account, in megabytes.
# Make sure this is an integer, without commas or spaces.
DEFAULT_MAX_STORAGE_SIZE=512

# Default filesystem to store uploaded files.
# Possible values: public|s3
DEFAULT_FILESYSTEM=public

# AWS keys for S3 when using this storage method
AWS_KEY=
AWS_SECRET=
AWS_REGION=us-east-1
AWS_BUCKET=
AWS_SERVER=

# Allow Two Factor Authentication feature on your instance
MFA_ENABLED=true

# Enable DAV support (beta feature)
DAV_ENABLED=false

# CLIENT ID and SECRET used for the official mobile application
# This is to make sure that only the mobile application that you approve can
# access the route to let your users sign in with their credentials
MOBILE_CLIENT_ID=
MOBILE_CLIENT_SECRET=

# Allow to access general statistics about your instance through a public API
# call
ALLOW_STATISTICS_THROUGH_PUBLIC_API_ACCESS=false

# Indicates that each user in the instance must comply to international policies
# like CASL or GDPR
POLICY_COMPLIANT=true

# Have access to paid features available on https://monicahq.com, for free.
# Can be true or false. Default to false.
# If set to true, that means your users will have to pay to access the paid
# features. We use Stripe to do this.
REQUIRES_SUBSCRIPTION=false

# Number of contacts allowed in the Free version if the instance requires
# a subscription
NUMBER_OF_ALLOWED_CONTACTS_FREE_ACCOUNT=10

# ONLY NECESSARY IF MONICA REQUIRES A SUBSCRIPTION TO WORK
# Leave blank unless you know what you are doing.
STRIPE_KEY=
STRIPE_SECRET=
PAID_PLAN_MONTHLY_FRIENDLY_NAME=
PAID_PLAN_MONTHLY_ID=
PAID_PLAN_MONTHLY_PRICE=
PAID_PLAN_ANNUAL_FRIENDLY_NAME=
PAID_PLAN_ANNUAL_ID=
PAID_PLAN_ANNUAL_PRICE=

# Enable geolocation services
# This is used to translate addresses to GPS coordinates.
ENABLE_GEOLOCATION=false

# API key for geolocation services
# We use LocationIQ (https://locationiq.com/) to translate addresses to
# latitude/longitude coordinates. We could use Google instead but we don't
# want to give anything to Google, ever.
# LocationIQ offers 10,000 free requests per day.
LOCATION_IQ_API_KEY=

# Enable weather on contact profile page
# Weather can only be fetched if we know longitude/latitude - this is why
# you also need to activate the geolocation service above to make it work
ENABLE_WEATHER=false

# Access to weather data from darksky api
# https://darksky.net/dev/register
# Darksky provides an api with 1000 free API calls per day
# You need to enable the weather above if you provide an API key here.
DARKSKY_API_KEY=

So - what am I doing wrong? Best regards,

Philip

jamzth commented 5 years ago

I'm also having the same exact issue, everything. Just wanted you to know that you're not alone ;)

Connor0308 commented 5 years ago

@jamzth : Even though I like the thought of not being alone, any help would be highly appreciated :-D.

wcypierre commented 5 years ago

@jamzth @Connor0308 did both of you also did the setup in a shared hosting environment? As I've tried replicating it on a vps and its working fine.

jamzth commented 5 years ago

@wcypierre yes, it was a shared environment for me. It looks like most of the database tables aren't being created. I only have migration and users tables in the db. Does that narrow anything down? I'm still looking around.

Connor0308 commented 5 years ago

Also complete confirmation from my side. I am using a shared hosting environment with SSH access. @wcypierre : When you ask on whether we "oth of you also did the setup in a shared hosting environment" it sounds to me as if there was a special How To for this scenario - did I miss something?

jamzth commented 5 years ago

@wcypierre @Connor0308 When I deleted the tables and tried to run php artisan migrate I got the following:

Migrating: 2014_10_12_000000_create_users_table

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))                                               

In PDOStatement.php line 119:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes                                        

In PDOStatement.php line 117:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes    

Makes me wonder if we are missing a step somewhere as well?

Connor0308 commented 5 years ago

@jamzth And once again: same on my side.

wcypierre commented 5 years ago

@jamzth @Connor0308 I asked about it because it seems like both of you are using shared hosting. well, it narrows down to where the issue only happens on shared hosting environment as I've tested it on a vps.

I did some search on laravel on shared hosting and it seems like there's some quirks to it in which I'm not familiar with.

I don't have a shared hosting account so gotta wait for the maintainers to reply on it.

Connor0308 commented 5 years ago

@wcypierre yes, it was a shared environment for me. It looks like most of the database tables aren't being created. [...].

Can we get a set on tables from somewhere? If the creation is the only issue, we could simply import them manually...

wcypierre commented 5 years ago

I think it would be best for you to specify the php, apache and mysql version used in the shared hosting for an easier troubleshoot for the maintainers

wcypierre commented 5 years ago

@wcypierre yes, it was a shared environment for me. It looks like most of the database tables aren't being created. [...].

Can we get a set on tables from somewhere? If the creation is the only issue, we could simply import them manually...

I could get you a copy from the one that I just created to get it running but you would still need to get the issue fixed though if you were to upgrade in the future

jamzth commented 5 years ago

@wcypierre I'd like to have that for a quick up and running solution until the fix or workaround is known. Thanks!

php 7.2 mysql 10.1.37-MariaDB-cll-lve apache 2.4.38

Connor0308 commented 5 years ago

@wcypierre Same from my side, the tables would be highly appreciated.

PHP: 7.2.14-nmml MySQL: 5.7.21 Apache: unknown

wcypierre commented 5 years ago

Here it is (I'm using MariaDB 10.1.38), try it out and see how it goes https://gist.github.com/wcypierre/82020218c31ca7659b949f9ca382afc9

jamzth commented 5 years ago

ok, so I managed to get the database created by specifying the following in boot() at app/Providers/AppServiceProviders.php

Schema::defaultStringLength(191);

Found this gem here: https://laravel-news.com/laravel-5-4-key-too-long-error

Still working on the rest of the install as I have time.

Connor0308 commented 5 years ago

I'll give it a try tonight. Thank you both

Connor0308 commented 5 years ago

@jamzth : Thank you for your support - That did the trick for me. The tables are created and I can login without any issue. @wcypierre : Thank you as well for your efforts.

cristobaltapia commented 5 years ago

I also have this problem, but the solution is not working for me. I added Schema::defaultStringLength(191); to the file and then run the migration script again, but the error is still there. What am I doing wrong?

(Edit)

/var/www/monica # php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migrating: 2018_12_22_200413_add_reminder_initial_date_to_reminders

In Connection.php line 664:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'monica.reminders' doesn'  
  t exist (SQL: alter table `reminders` add `initial_date` date not null after `conta  
  ct_id`, add `delible` tinyint(1) not null default '1' after `next_expected_date`)    

In PDOStatement.php line 119:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'monica.reminders' doesn'  
  t exist                                                                              

In PDOStatement.php line 117:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'monica.reminders' doesn'  
  t exist                                                                              
github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.