Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: relation "user" does not exist #822

Closed
tinchoz49 opened this issue Oct 29, 2024 · 4 comments
Closed

fix: relation "user" does not exist #822

tinchoz49 opened this issue Oct 29, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@tinchoz49
Copy link

Describe the bug

Hey guys, i'm trying to start the self hosted version and I'm getting this error in the frontend login.

Environment:


Request Method: POST
Request URL: http://frontend.unstract.localhost/api/v1/login

Django Version: 4.2.1
Python Version: 3.9.20
Installed Applications:
['corsheaders',
 'account_v2',
 'account_usage',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admindocs',
 'rest_framework',
 'social_django',
 'drf_yasg',
 'docs',
 'plugins',
 'feature_flag',
 'django_celery_beat',
 'migrating.v2',
 'connector_auth_v2',
 'tenant_account_v2',
 'connector_v2',
 'adapter_processor_v2',
 'file_management',
 'workflow_manager.endpoint_v2',
 'workflow_manager.workflow_v2',
 'tool_instance_v2',
 'pipeline_v2',
 'platform_settings_v2',
 'api_v2',
 'usage_v2',
 'notification_v2',
 'prompt_studio.prompt_profile_manager_v2',
 'prompt_studio.prompt_studio_v2',
 'prompt_studio.prompt_studio_core_v2',
 'prompt_studio.prompt_studio_registry_v2',
 'prompt_studio.prompt_studio_output_manager_v2',
 'prompt_studio.prompt_studio_document_manager_v2',
 'prompt_studio.prompt_studio_index_manager_v2']
Installed Middleware:
['log_request_id.middleware.RequestIDMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'middleware.organization_middleware.OrganizationMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'account_v2.custom_auth_middleware.CustomAuthMiddleware',
 'middleware.exception.ExceptionLoggingMiddleware',
 'social_django.middleware.SocialAuthExceptionMiddleware',
 'middleware.remove_allow_header.RemoveAllowHeaderMiddleware',
 'middleware.cache_control.CacheControlMiddleware']



Traceback (most recent call last):
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

The above exception (relation "user" does not exist
LINE 1: ...", "user"."modified_at", "user"."created_at" FROM "user" WHE...
                                                             ^
) was the direct cause of the following exception:
  File "/app/.venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/app/.venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/app/.venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
  File "/app/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/app/.venv/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/app/.venv/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/app/.venv/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/app/.venv/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/app/.venv/lib/python3.9/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/app/account_v2/views.py", line 59, in login
    return auth_controller.user_login(request)
  File "/app/account_v2/authentication_controller.py", line 73, in user_login
    return self.auth_service.user_login(request)
  File "/app/account_v2/authentication_service.py", line 63, in user_login
    if self.authenticate_and_login(request, username, password):
  File "/app/account_v2/authentication_service.py", line 93, in authenticate_and_login
    user = authenticate(request, username=username, password=password)
  File "/app/.venv/lib/python3.9/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper
    return func(*func_args, **func_kwargs)
  File "/app/.venv/lib/python3.9/site-packages/django/contrib/auth/__init__.py", line 77, in authenticate
    user = backend.authenticate(request, **credentials)
  File "/app/.venv/lib/python3.9/site-packages/django/contrib/auth/backends.py", line 46, in authenticate
    user = UserModel._default_manager.get_by_natural_key(username)
  File "/app/.venv/lib/python3.9/site-packages/django/contrib/auth/base_user.py", line 54, in get_by_natural_key
    return self.get(**{self.model.USERNAME_FIELD: username})
  File "/app/.venv/lib/python3.9/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 633, in get
    num = len(clone)
  File "/app/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 380, in __len__
    self._fetch_all()
  File "/app/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 1881, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/app/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 91, in __iter__
    results = compiler.execute_sql(
  File "/app/.venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1560, in execute_sql
    cursor.execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 102, in execute
    return super().execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /api/v1/login
Exception Value: relation "user" does not exist
LINE 1: ...", "user"."modified_at", "user"."created_at" FROM "user" WHE...                                                    

To reproduce

  1. ./run-platform.sh
  2. go the frontend and try to login with the default credentials.

Expected behavior

I expect to enter to the dashboard.

Environment details

  • v0.93.1
  • MacOS 15.0.1
  • i'm using orbstack as the docker solution

Additional context

I check the database and it seems that the backend migrations are not being running.

Screenshots

This is the log of the backend:

Migration initiated
WARNING : [2024-10-29 13:08:16,067]{module:register process:7 thread:140737481631552 request_id:none} :- No connector found.
WARNING : [2024-10-29 13:08:18,802]{module:register process:7 thread:140737481631552 request_id:none} :- Unable to import embedding adapters : No module named 'llama_index.embeddings.huggingface'
WARNING : [2024-10-29 13:08:19,213]{module:register process:7 thread:140737481631552 request_id:none} :- Unable to import embedding adapters : No module named 'llama_index.embeddings.fastembed'
WARNING : [2024-10-29 13:08:26,326]{module:register process:7 thread:140737481631552 request_id:none} :- Unable to import vectorDB adapters : No module named 'llama_index.vector_stores.supabase'
INFO : [2024-10-29 13:08:30,007]{module:base process:7 thread:140737481631552 request_id:none} :- DB connection (ID: 140736457058560) is established or reused.
WARNING : [2024-10-29 13:08:30,010]{module:execution_log_utils process:7 thread:140737481631552 request_id:none} :- ProgrammingError occurred while creating log consumer scheduler. If you are currently running migrations for new environment, you can ignore this warning
WARNING : [2024-10-29 13:08:30,162]{module:authentication_plugin_registry process:7 thread:140737481631552 request_id:none} :- Metadata is not active for auth_sample authentication module.
WARNING : [2024-10-29 13:08:30,162]{module:authentication_plugin_registry process:7 thread:140737481631552 request_id:none} :- No authentication modules found.Application will start without authentication module
WARNING : [2024-10-29 13:08:30,553]{module:tool_utils process:7 thread:140737481631552 request_id:none} :- Could not find tool registry YAML: /data/tool_registry_config/registry.yaml
INFO : [2024-10-29 13:08:30,706]{module:processor_loader process:7 thread:140737481631552 request_id:none} :- No processor plugins found.
Operations to perform:
  Apply all migrations: account_usage, account_v2, adapter_processor_v2, admin, api_v2, auth, connector_auth_v2, connector_v2, contenttypes, django_celery_beat, endpoint_v2, notification_v2, pipeline_v2, prompt_profile_manager_v2, prompt_studio_core_v2, prompt_studio_document_manager_v2, prompt_studio_index_manager_v2, prompt_studio_output_manager_v2, prompt_studio_registry_v2, prompt_studio_v2, sessions, social_django, tenant_account_v2, tool_instance_v2, usage_v2, workflow_v2
Running migrations:
Traceback (most recent call last):
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
psycopg2.errors.InvalidSchemaName: no schema has been selected to create in
LINE 1: CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...
                     ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/.venv/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 70, in ensure_schema
    editor.create_model(self.Migration)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 451, in create_model
    self.execute(sql, params or None)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/postgresql/schema.py", line 45, in execute
    return super().execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 201, in execute
    cursor.execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 102, in execute
    return super().execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.venv/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/app/.venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: no schema has been selected to create in
LINE 1: CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...
                     ^


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/manage.py", line 29, in <module>
    main()
  File "/app/manage.py", line 25, in main
    execute_from_command_line(sys.argv)
  File "/app/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/app/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/app/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/app/.venv/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
  File "/app/.venv/lib/python3.9/site-packages/django/db/migrations/executor.py", line 107, in migrate
    self.recorder.ensure_schema()
  File "/app/.venv/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 72, in ensure_schema
    raise MigrationSchemaMissing(
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (no schema has been selected to create in
LINE 1: CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...
                     ^
)
[2024-10-29 13:08:33 +0000] [27] [DEBUG] Current configuration:
  config: ./gunicorn.conf.py
  wsgi_app: None
  bind: ['0.0.0.0:8000']
  backlog: 2048
  workers: 2
  worker_class: sync
  threads: 2
  worker_connections: 1000
  max_requests: 0
  max_requests_jitter: 0
  timeout: 600
  graceful_timeout: 30
  keepalive: 2
  limit_request_line: 4094
  limit_request_fields: 100
  limit_request_field_size: 8190
  reload: False
  reload_engine: auto
  reload_extra_files: []
  spew: False
  check_config: False
  print_config: False
  preload_app: False
  sendfile: None
  reuse_port: False
  chdir: /app
  daemon: False
  raw_env: []
  pidfile: None
  worker_tmp_dir: None
  user: 0
  group: 0
  umask: 0
  initgroups: False
  tmp_upload_dir: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  forwarded_allow_ips: ['127.0.0.1', '::1']
  accesslog: -
  disable_redirect_access_to_syslog: False
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  errorlog: -
  loglevel: debug
  capture_output: False
  logger_class: gunicorn.glogging.Logger
  logconfig: None
  logconfig_dict: {}
  logconfig_json: None
  syslog_addr: udp://localhost:514
  syslog: False
  syslog_prefix: None
  syslog_facility: user
  enable_stdio_inheritance: False
  statsd_host: None
  dogstatsd_tags: 
  statsd_prefix: 
  proc_name: None
  default_proc_name: backend.wsgi:application
  pythonpath: None
  paste: None
  on_starting: <function OnStarting.on_starting at 0x7ffffec5baf0>
  on_reload: <function OnReload.on_reload at 0x7ffffec5bc10>
  when_ready: <function WhenReady.when_ready at 0x7ffffec5bd30>
  pre_fork: <function Prefork.pre_fork at 0x7ffffec5be50>
  post_fork: <function Postfork.post_fork at 0x7ffffec5bf70>
  post_worker_init: <function PostWorkerInit.post_worker_init at 0x7ffffec400d0>
  worker_int: <function WorkerInt.worker_int at 0x7ffffec401f0>
  worker_abort: <function WorkerAbort.worker_abort at 0x7ffffec40310>
  pre_exec: <function PreExec.pre_exec at 0x7ffffec40430>
  pre_request: <function PreRequest.pre_request at 0x7ffffec40550>
  post_request: <function PostRequest.post_request at 0x7ffffec405e0>
  child_exit: <function ChildExit.child_exit at 0x7ffffec40700>
  worker_exit: <function WorkerExit.worker_exit at 0x7ffffec40820>
  nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7ffffec40940>
  on_exit: <function OnExit.on_exit at 0x7ffffec40a60>
  ssl_context: <function NewSSLContext.ssl_context at 0x7ffffec40b80>
  proxy_protocol: False
  proxy_allow_ips: ['127.0.0.1', '::1']
  keyfile: None
  certfile: None
  ssl_version: 2
  cert_reqs: 0
  ca_certs: None
  suppress_ragged_eofs: True
  do_handshake_on_connect: False
  ciphers: None
  raw_paste_global_conf: []
  permit_obsolete_folding: False
  strip_header_spaces: False
  permit_unconventional_http_method: False
  permit_unconventional_http_version: False
  casefold_http_method: False
  forwarder_headers: ['SCRIPT_NAME', 'PATH_INFO']
  header_map: drop
[2024-10-29 13:08:33 +0000] [27] [INFO] Starting gunicorn 23.0.0
[2024-10-29 13:08:33 +0000] [27] [DEBUG] Arbiter booted
[2024-10-29 13:08:33 +0000] [27] [INFO] Listening at: http://0.0.0.0:8000 (27)
[2024-10-29 13:08:33 +0000] [27] [INFO] Using worker: gthread
[2024-10-29 13:08:33 +0000] [28] [INFO] Booting worker with pid: 28
[2024-10-29 13:08:33 +0000] [29] [INFO] Booting worker with pid: 29
[2024-10-29 13:08:33 +0000] [27] [DEBUG] 2 workers
@tinchoz49 tinchoz49 added the bug Something isn't working label Oct 29, 2024
@tinchoz49 tinchoz49 changed the title fix: [ISSUE] fix: relation "user" does not exist Oct 29, 2024
@chandrasekharan-zipstack
Copy link
Contributor

Hello @tinchoz49, thanks for trying out Unstract.

This is a known issue which got introduced in v0.93.0. This has been fixed by PR #820 and will be released soon.
Will keep you posted in this thread once its released

@tinchoz49
Copy link
Author

thank you guys!

@chandrasekharan-zipstack
Copy link
Contributor

@tinchoz49 we've released v0.93.2 to help fix this issue. Please try this fix out, I also suggest doing it in a fresh clone / environment

@tinchoz49
Copy link
Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants