39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
docker run -d `
|
||
--name postgres17 `
|
||
-e POSTGRES_PASSWORD=postgres `
|
||
-e POSTGRES_USER=postgres `
|
||
-e POSTGRES_DB=inventory_db `
|
||
-p 5432:5432 `
|
||
-v postgres17-data:/var/lib/postgresql/data `
|
||
postgres:17
|
||
|
||
# 2. Создаем миграции с нуля
|
||
python manage.py makemigrations
|
||
|
||
# 3. Применяем все миграции
|
||
python manage.py migrate
|
||
|
||
# 4. Создаем главного тенанта (если нужно)
|
||
python manage.py shell
|
||
# Внутри shell:
|
||
from tenants.models import Client, Domain
|
||
client = Client.objects.create(
|
||
name='Main',
|
||
schema_name='public'
|
||
)
|
||
Domain.objects.create(
|
||
domain='localhost',
|
||
tenant=client,
|
||
is_primary=True
|
||
)
|
||
# Добавляем 127.0.0.1 как синоним localhost (иначе админка по 127.0.0.1 не будет работать)
|
||
Domain.objects.create(
|
||
domain='127.0.0.1',
|
||
tenant=client,
|
||
is_primary=False
|
||
)
|
||
exit()
|
||
|
||
# 5. Создаем суперпользователя для public схемы
|
||
python manage.py createsuperuser
|