markdown Django迁移

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Django迁移相关的知识,希望对你有一定的参考价值。

# Django Migrations

### dbshell

```bash
$ python manage.py dbshell
```

- For PostgreSQL, this runs the psql command-line client.
- For MySQL, this runs the mysql command-line client.
- For SQLite, this runs the sqlite3 command-line client.
- For Oracle, this runs the sqlplus command-line client.


### Listing Out Migrations

```bash
$ ./manage.py showmigrations
```

### Naming Migrations

```bash
$ ./manage.py makemigrations historical_data --name 0002_switch_to_decimals
```




## You want to clear all the migration history but you want to keep the existing database.


### 1. Make sure your models fits the current database schema

```bash
$ python manage.py makemigrations
```

*If there are any pending migration, apply them first.*

### 2. Clear the migration history for each app

```bash
$ python manage.py showmigrations
$ python manage.py migrate --fake core zero
```

*Clear the migration history (please note that core is the name of my app)*

### 3. Remove the actual migration files.

### 4. Create the initial migrations

```bash
$ python manage.py makemigrations
```

### 5. Fake the initial migration

```bash
$ python manage.py migrate --fake-initial
```

https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html

以上是关于markdown Django迁移的主要内容,如果未能解决你的问题,请参考以下文章

Django搭建个人博客平台3---博客表结构设计和markdown编辑器

markdown 迁移模块 - 迁移CSV

markdown 将EngineYard迁移到更新的堆栈

markdown 将EngineYard迁移到更新的堆栈

markdown 一些更多的迁移命令

markdown Prisma迁移