A large number of small tooling and README updates.
This commit is contained in:
parent
adc24ec91e
commit
937d36de31
8 changed files with 76 additions and 81 deletions
48
readme.md
48
readme.md
|
@ -5,11 +5,11 @@ This code runs https://www.themotte.org .
|
|||
|
||||
# Installation (Windows/Linux/MacOS)
|
||||
|
||||
1 - Install Docker on your machine.
|
||||
1 - Install [a container runtime and the Docker commandline tools](https://docs.docker.com/get-docker/) on your machine.
|
||||
|
||||
[Docker installation](https://docs.docker.com/get-docker/)
|
||||
On Windows, Docker will pester you to pay them money for licensing. If you want something less proprietary, consider [Container Desktop](https://container-desktop.io) or [Stevedore](http://github.com/slonopotamus/stevedore) instead.
|
||||
|
||||
2 - If hosting on localhost and/or without HTTPS, change```"SESSION_COOKIE_SECURE"``` in ```__main__.py``` to "False"
|
||||
2 - Install [Git](https://git-scm.com/). If you're on Windows and want a GUI, [Github Desktop](https://desktop.github.com/) is quite nice.
|
||||
|
||||
3 - Run the following commands in the terminal:
|
||||
|
||||
|
@ -18,12 +18,14 @@ git clone https://github.com/themotte/rDrama/
|
|||
|
||||
cd rDrama
|
||||
|
||||
docker-compose up
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
The first time you do this, it will take a while. It'll be (much) faster next time.
|
||||
|
||||
4 - That's it! Visit `localhost` in your browser.
|
||||
|
||||
5 - Optional: to change the domain from "localhost" to something else and configure the site settings, as well as integrate it with the external services the website uses, please edit the variables in the `env` file and then restart the docker container.
|
||||
Code edits will be reflected (almost) immediately. If you make any setup changes or database changes, you'll need to ctrl-C the docker-compose status log and run `docker-compose up --build` again.
|
||||
|
||||
# Run the E2E tests:
|
||||
|
||||
|
@ -54,14 +56,13 @@ As an example, let's say we want to add a column `is\_flagged` to the `comments`
|
|||
...
|
||||
+ is_flagged = Column(Boolean, default=False, nullable=False)
|
||||
```
|
||||
|
||||
2. Autogenerate a migration with a descriptive message. To do this, run
|
||||
```sh
|
||||
flask db revision --autogenerate --message="add is_flagged field to comments"
|
||||
./util/command.py db revision --autogenerate --message="add is_flagged field to comments"
|
||||
```
|
||||
from the flask server within the directory the flask app is being served from, with an env var of `FLASK\_APP="files/cli:app"`. If you are running flask using `docker-compose` as described above, this looks like
|
||||
```sh
|
||||
docker-compose exec -T files bash -c 'cd /service/; FLASK_APP="files/cli:app" flask "$@"' . db revision --autogenerate --message="add is_flagged field to comments"
|
||||
```
|
||||
|
||||
This will create a migration in the `migrations/versions` directory with a name like `migrations/versions/2022\_05\_23\_05\_38\_40\_9c27db0b3918\_add\_is\_flagged\_field\_to\_comments.py` and content like
|
||||
```python
|
||||
"""add is_flagged field to comments
|
||||
|
@ -83,33 +84,12 @@ def downgrade():
|
|||
```
|
||||
|
||||
3. Examine the autogenerated migration to make sure that everything looks right (it adds the column you expected it to add and nothing else, all constraints are named, etc. If you see a `None` in one of the alembic operations, e.g. `op.create\_foreign\_key\_something(None, 'usernotes', 'users', ['author\_id'])`, please replace it with a descriptive string before you commit the migration).
|
||||
4. Run the migration to make sure it works. You can run a migration with the command
|
||||
|
||||
4. Restart the Docker container to make sure it works.
|
||||
|
||||
```sh
|
||||
flask db upgrade
|
||||
docker-compose up --build
|
||||
```
|
||||
which, if you're using the docker-compose, looks like
|
||||
```sh
|
||||
docker-compose exec -T files bash -c 'cd /service/; FLASK_APP="files/cli:app" flask "$@"' . db upgrade
|
||||
```
|
||||
|
||||
Or with the util scripts:
|
||||
```sh
|
||||
./util/migrate.py upgrade
|
||||
```
|
||||
|
||||
## Running migrations someone else checked in
|
||||
|
||||
If you've just merged schema changes that another dev made, you can get your local database up to date by:
|
||||
|
||||
* Open two terminals in the root of the project
|
||||
* Run `docker-compose up` in one terminal
|
||||
* Run this command in the other:
|
||||
```sh
|
||||
./util/test.py upgrade
|
||||
```
|
||||
(or see above section for manual upgrade command)
|
||||
|
||||
You should not have to reboot your container, though it might be a good idea to do so anyway if the changes you are merging in are nontrivial (particularly if there have been changes to `docker-compose.yml` or `Dockerfile`).
|
||||
|
||||
## So what's up with schema.sql, can I just change that?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue