prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Create a Deployment type 1 specific  script.
  Create a script to download docker-compose from the Mathesar repo and help the user in setting up Mathesar.
  
  - [ ] The script should be self-documenting, i.e., the prompts during interactive portions should help the user understand the implications of what they're doing, and any error states should give enough info for the user to find solutions in the troubleshooting documentation on docs.mathesar.org
   
  - [ ] The script should also  add help text in the installation CLI that would list the database Privileges needed for Mathesar to function effectively.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `install.py`
  Content:
  ```
  1 """
  2 This script installs functions and types for Mathesar onto the configured DB.
  3 """
  4 import getopt
  5 import sys
  6 
  7 import getpass
  8 
  9 import django
  10 from decouple import UndefinedValueError, config as decouple_config
  11 from django.contrib.auth import get_user_model
  12 from django.core import management
  13 
  14 from django.conf import settings
  15 from db import install
  16 
  17 
  18 def main():
  19     skip_confirm = False
  20     (opts, _) = getopt.getopt(sys.argv[1:], ":s", ["skip-confirm"])
  21     for (opt, value) in opts:
  22         if (opt == "-s") or (opt == "--skip-confirm"):
  23             skip_confirm = True
  24     check_missing_dj_config()
  25     django.setup()
  26     management.call_command('migrate')
  27     debug_mode = decouple_config('DEBUG', default=False, cast=bool)
  28     #
  29     if not debug_mode:
  30         management.call_command('collectstatic', no_input='y')
  31     if not superuser_exists():
  32         print("------------Setting up Admin user------------")
  33         print("Admin user does not exists. We need at least one admin")
  34         create_superuser(skip_confirm)
  35 
  36     print("------------Setting up User Databases------------")
  37     user_databases = [key for key in settings.DATABASES if key != "default"]
  38     for database_key in user_databases:
  39         install_on_db_with_key(database_key, skip_confirm)
  40 
  41 
  42 def superuser_exists():
  43     return get_user_model().objects.filter(is_superuser=True).exists()
  44 
  45 
  46 def create_superuser(skip_confirm):
  47     # TODO Replace argument name used for default admin user creation.
  48     if not skip_confirm:
  49         print("Please enter the details to create a new admin user ")
  50         username = input("Username: ")
  51         email = input("Email: ")
  52         password = getpass.getpass('Password: ')
  53     else:
  54         username = "admin"
  55         email = "admin@example.com"
  56         password = "password"
  57     get_user_model().objects.create_superuser(username, email, password)
  58     print(f"Admin user with username {username} was created successfully")
  59 
  60 
  61 def check_missing_dj_config():
  62     # TODO Add documentation link
  63     documentation_link = ""
  64     try:
  65         decouple_config('ALLOWED_HOSTS')
  66         decouple_config('SECRET_KEY')
  67         decouple_config('DJANGO_DATABASE_KEY')
  68         decouple_config('DJANGO_SETTINGS_MODULE')
  69         decouple_config('DJANGO_DATABASE_URL')
  70         decouple_config('MATHESAR_DATABASES')
  71     except UndefinedValueError as e:
  72         missing_config_key = e.args[0]
  73         raise Exception(f"{missing_config_key} environment variable is missing."
  74                         f" Please follow the documentation {documentation_link} to add the missing environment variable.")
  75 
  76 
  77 def install_on_db_with_key(database_key, skip_confirm):
  78     install.install_mathesar(
  79         database_name=settings.DATABASES[database_key]["NAME"],
  80         username=settings.DATABASES[database_key]["USER"],
  81         password=settings.DATABASES[database_key]["PASSWORD"],
  82         hostname=settings.DATABASES[database_key]["HOST"],
  83         port=settings.DATABASES[database_key]["PORT"],
  84         skip_confirm=skip_confirm
  85     )
  86 
  87 
  88 if __name__ == "__main__":
  89     main()
  90
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/install.py b/install.py
  --- a/install.py
  +++ b/install.py
  @@ -4,11 +4,7 @@
   import getopt
   import sys
   
  -import getpass
  -
   import django
  -from decouple import UndefinedValueError, config as decouple_config
  -from django.contrib.auth import get_user_model
   from django.core import management
   
   from django.conf import settings
  @@ -16,64 +12,20 @@
   
   
   def main():
  -    skip_confirm = False
  +    # skip_confirm is temporarily enabled by default as we don't have any use for interactive prompts with docker only deployments
  +    skip_confirm = True
       (opts, _) = getopt.getopt(sys.argv[1:], ":s", ["skip-confirm"])
       for (opt, value) in opts:
           if (opt == "-s") or (opt == "--skip-confirm"):
               skip_confirm = True
  -    check_missing_dj_config()
       django.setup()
       management.call_command('migrate')
  -    debug_mode = decouple_config('DEBUG', default=False, cast=bool)
  -    #
  -    if not debug_mode:
  -        management.call_command('collectstatic', no_input='y')
  -    if not superuser_exists():
  -        print("------------Setting up Admin user------------")
  -        print("Admin user does not exists. We need at least one admin")
  -        create_superuser(skip_confirm)
  -
       print("------------Setting up User Databases------------")
       user_databases = [key for key in settings.DATABASES if key != "default"]
       for database_key in user_databases:
           install_on_db_with_key(database_key, skip_confirm)
   
   
  -def superuser_exists():
  -    return get_user_model().objects.filter(is_superuser=True).exists()
  -
  -
  -def create_superuser(skip_confirm):
  -    # TODO Replace argument name used for default admin user creation.
  -    if not skip_confirm:
  -        print("Please enter the details to create a new admin user ")
  -        username = input("Username: ")
  -        email = input("Email: ")
  -        password = getpass.getpass('Password: ')
  -    else:
  -        username = "admin"
  -        email = "admin@example.com"
  -        password = "password"
  -    get_user_model().objects.create_superuser(username, email, password)
  -    print(f"Admin user with username {username} was created successfully")
  -
  -
  -def check_missing_dj_config():
  -    # TODO Add documentation link
  -    documentation_link = ""
  -    try:
  -        decouple_config('ALLOWED_HOSTS')
  -        decouple_config('SECRET_KEY')
  -        decouple_config('DJANGO_DATABASE_KEY')
  -        decouple_config('DJANGO_SETTINGS_MODULE')
  -        decouple_config('DJANGO_DATABASE_URL')
  -        decouple_config('MATHESAR_DATABASES')
  -    except UndefinedValueError as e:
  -        missing_config_key = e.args[0]
  -        raise Exception(f"{missing_config_key} environment variable is missing."
  -                        f" Please follow the documentation {documentation_link} to add the missing environment variable.")
  -
  -
   def install_on_db_with_key(database_key, skip_confirm):
       install.install_mathesar(
           database_name=settings.DATABASES[database_key]["NAME"],
  
verification_info: {"golden_diff": "diff --git a/install.py b/install.py\n--- a/install.py\n+++ b/install.py\n@@ -4,11 +4,7 @@\n import getopt\n import sys\n \n-import getpass\n-\n import django\n-from decouple import UndefinedValueError, config as decouple_config\n-from django.contrib.auth import get_user_model\n from django.core import management\n \n from django.conf import settings\n@@ -16,64 +12,20 @@\n \n \n def main():\n-    skip_confirm = False\n+    # skip_confirm is temporarily enabled by default as we don't have any use for interactive prompts with docker only deployments\n+    skip_confirm = True\n     (opts, _) = getopt.getopt(sys.argv[1:], \":s\", [\"skip-confirm\"])\n     for (opt, value) in opts:\n         if (opt == \"-s\") or (opt == \"--skip-confirm\"):\n             skip_confirm = True\n-    check_missing_dj_config()\n     django.setup()\n     management.call_command('migrate')\n-    debug_mode = decouple_config('DEBUG', default=False, cast=bool)\n-    #\n-    if not debug_mode:\n-        management.call_command('collectstatic', no_input='y')\n-    if not superuser_exists():\n-        print(\"------------Setting up Admin user------------\")\n-        print(\"Admin user does not exists. We need at least one admin\")\n-        create_superuser(skip_confirm)\n-\n     print(\"------------Setting up User Databases------------\")\n     user_databases = [key for key in settings.DATABASES if key != \"default\"]\n     for database_key in user_databases:\n         install_on_db_with_key(database_key, skip_confirm)\n \n \n-def superuser_exists():\n-    return get_user_model().objects.filter(is_superuser=True).exists()\n-\n-\n-def create_superuser(skip_confirm):\n-    # TODO Replace argument name used for default admin user creation.\n-    if not skip_confirm:\n-        print(\"Please enter the details to create a new admin user \")\n-        username = input(\"Username: \")\n-        email = input(\"Email: \")\n-        password = getpass.getpass('Password: ')\n-    else:\n-        username = \"admin\"\n-        email = \"admin@example.com\"\n-        password = \"password\"\n-    get_user_model().objects.create_superuser(username, email, password)\n-    print(f\"Admin user with username {username} was created successfully\")\n-\n-\n-def check_missing_dj_config():\n-    # TODO Add documentation link\n-    documentation_link = \"\"\n-    try:\n-        decouple_config('ALLOWED_HOSTS')\n-        decouple_config('SECRET_KEY')\n-        decouple_config('DJANGO_DATABASE_KEY')\n-        decouple_config('DJANGO_SETTINGS_MODULE')\n-        decouple_config('DJANGO_DATABASE_URL')\n-        decouple_config('MATHESAR_DATABASES')\n-    except UndefinedValueError as e:\n-        missing_config_key = e.args[0]\n-        raise Exception(f\"{missing_config_key} environment variable is missing.\"\n-                        f\" Please follow the documentation {documentation_link} to add the missing environment variable.\")\n-\n-\n def install_on_db_with_key(database_key, skip_confirm):\n     install.install_mathesar(\n         database_name=settings.DATABASES[database_key][\"NAME\"],\n", "issue": "Create a Deployment type 1 specific  script.\nCreate a script to download docker-compose from the Mathesar repo and help the user in setting up Mathesar.\r\n\r\n- [ ] The script should be self-documenting, i.e., the prompts during interactive portions should help the user understand the implications of what they're doing, and any error states should give enough info for the user to find solutions in the troubleshooting documentation on docs.mathesar.org\r\n \r\n- [ ] The script should also  add help text in the installation CLI that would list the database Privileges needed for Mathesar to function effectively.\n", "before_files": [{"content": "\"\"\"\nThis script installs functions and types for Mathesar onto the configured DB.\n\"\"\"\nimport getopt\nimport sys\n\nimport getpass\n\nimport django\nfrom decouple import UndefinedValueError, config as decouple_config\nfrom django.contrib.auth import get_user_model\nfrom django.core import management\n\nfrom django.conf import settings\nfrom db import install\n\n\ndef main():\n    skip_confirm = False\n    (opts, _) = getopt.getopt(sys.argv[1:], \":s\", [\"skip-confirm\"])\n    for (opt, value) in opts:\n        if (opt == \"-s\") or (opt == \"--skip-confirm\"):\n            skip_confirm = True\n    check_missing_dj_config()\n    django.setup()\n    management.call_command('migrate')\n    debug_mode = decouple_config('DEBUG', default=False, cast=bool)\n    #\n    if not debug_mode:\n        management.call_command('collectstatic', no_input='y')\n    if not superuser_exists():\n        print(\"------------Setting up Admin user------------\")\n        print(\"Admin user does not exists. We need at least one admin\")\n        create_superuser(skip_confirm)\n\n    print(\"------------Setting up User Databases------------\")\n    user_databases = [key for key in settings.DATABASES if key != \"default\"]\n    for database_key in user_databases:\n        install_on_db_with_key(database_key, skip_confirm)\n\n\ndef superuser_exists():\n    return get_user_model().objects.filter(is_superuser=True).exists()\n\n\ndef create_superuser(skip_confirm):\n    # TODO Replace argument name used for default admin user creation.\n    if not skip_confirm:\n        print(\"Please enter the details to create a new admin user \")\n        username = input(\"Username: \")\n        email = input(\"Email: \")\n        password = getpass.getpass('Password: ')\n    else:\n        username = \"admin\"\n        email = \"admin@example.com\"\n        password = \"password\"\n    get_user_model().objects.create_superuser(username, email, password)\n    print(f\"Admin user with username {username} was created successfully\")\n\n\ndef check_missing_dj_config():\n    # TODO Add documentation link\n    documentation_link = \"\"\n    try:\n        decouple_config('ALLOWED_HOSTS')\n        decouple_config('SECRET_KEY')\n        decouple_config('DJANGO_DATABASE_KEY')\n        decouple_config('DJANGO_SETTINGS_MODULE')\n        decouple_config('DJANGO_DATABASE_URL')\n        decouple_config('MATHESAR_DATABASES')\n    except UndefinedValueError as e:\n        missing_config_key = e.args[0]\n        raise Exception(f\"{missing_config_key} environment variable is missing.\"\n                        f\" Please follow the documentation {documentation_link} to add the missing environment variable.\")\n\n\ndef install_on_db_with_key(database_key, skip_confirm):\n    install.install_mathesar(\n        database_name=settings.DATABASES[database_key][\"NAME\"],\n        username=settings.DATABASES[database_key][\"USER\"],\n        password=settings.DATABASES[database_key][\"PASSWORD\"],\n        hostname=settings.DATABASES[database_key][\"HOST\"],\n        port=settings.DATABASES[database_key][\"PORT\"],\n        skip_confirm=skip_confirm\n    )\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "install.py"}], "after_files": [{"content": "\"\"\"\nThis script installs functions and types for Mathesar onto the configured DB.\n\"\"\"\nimport getopt\nimport sys\n\nimport django\nfrom django.core import management\n\nfrom django.conf import settings\nfrom db import install\n\n\ndef main():\n    # skip_confirm is temporarily enabled by default as we don't have any use for interactive prompts with docker only deployments\n    skip_confirm = True\n    (opts, _) = getopt.getopt(sys.argv[1:], \":s\", [\"skip-confirm\"])\n    for (opt, value) in opts:\n        if (opt == \"-s\") or (opt == \"--skip-confirm\"):\n            skip_confirm = True\n    django.setup()\n    management.call_command('migrate')\n    print(\"------------Setting up User Databases------------\")\n    user_databases = [key for key in settings.DATABASES if key != \"default\"]\n    for database_key in user_databases:\n        install_on_db_with_key(database_key, skip_confirm)\n\n\ndef install_on_db_with_key(database_key, skip_confirm):\n    install.install_mathesar(\n        database_name=settings.DATABASES[database_key][\"NAME\"],\n        username=settings.DATABASES[database_key][\"USER\"],\n        password=settings.DATABASES[database_key][\"PASSWORD\"],\n        hostname=settings.DATABASES[database_key][\"HOST\"],\n        port=settings.DATABASES[database_key][\"PORT\"],\n        skip_confirm=skip_confirm\n    )\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "install.py"}]}