Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mogita/feat/postgres
Feat: postgres
- Loading branch information
Showing
19 changed files
with
698 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_pg | ||
redis-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM python:3.8-bullseye | ||
|
||
# Comment the following line if you don't need an alternative debian software source | ||
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && rm -Rf /var/lib/apt/lists/* && apt-get update | ||
RUN apt-get update | ||
RUN apt-get install -y git | ||
|
||
WORKDIR /app | ||
|
||
RUN wget https://github.com.cnpmjs.org/golang-migrate/migrate/releases/download/v4.15.1/migrate.linux-amd64.tar.gz -O migrate.linux-amd64.tar.gz | ||
RUN tar -xvf migrate.linux-amd64.tar.gz -C /usr/local/bin | ||
RUN chmod a+x /usr/local/bin/migrate | ||
|
||
RUN git clone https://github.com.cnpmjs.org/vishnubob/wait-for-it.git /wait-for-it | ||
RUN chmod a+x /wait-for-it/wait-for-it.sh | ||
|
||
COPY migrate.sh /app/migrate.sh | ||
RUN chmod a+x /app/migrate.sh | ||
|
||
COPY migrations /app/migrations | ||
|
||
CMD ["/wait-for-it/wait-for-it.sh", "douban-crawler-db:5432", "--", "/app/migrate.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
echo "running migration..." | ||
|
||
/usr/local/bin/migrate -database "postgres://crawler:crawler@douban-crawler-db:5432/crawler?sslmode=disable&search_path=public" -path /app/migrations up | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS books; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
CREATE TABLE IF NOT EXISTS books ( | ||
id bigserial PRIMARY KEY, | ||
title text DEFAULT '', | ||
subtitle text DEFAULT '', | ||
author text DEFAULT '', | ||
author_url text DEFAULT '', | ||
author_intro text DEFAULT '', | ||
publisher text DEFAULT '', | ||
published_at timestamp without time zone DEFAULT NULL, | ||
original_title text DEFAULT '', | ||
translator text DEFAULT '', | ||
producer text DEFAULT '', | ||
series text DEFAULT '', | ||
price text DEFAULT '', | ||
isbn text DEFAULT '', | ||
pages int DEFAULT 0, | ||
bookbinding text DEFAULT '', | ||
book_intro text DEFAULT '', | ||
toc text DEFAULT '', | ||
rating real DEFAULT 0.0, | ||
rating_count int DEFAULT 0, | ||
cover_img_url text DEFAULT '', | ||
origin text DEFAULT '', | ||
origin_id text DEFAULT '', | ||
origin_url text UNIQUE DEFAULT '', | ||
crawled boolean DEFAULT False, | ||
created_at timestamp without time zone default (now() at time zone 'utc'), | ||
updated_at timestamp without time zone default (now() at time zone 'utc'), | ||
deleted_at timestamp without time zone default NULL | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS tags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE TABLE IF NOT EXISTS tags ( | ||
id bigserial PRIMARY KEY, | ||
name text UNIQUE NOT NULL, | ||
current_page bigint DEFAULT 0, | ||
created_at timestamp without time zone default (now() at time zone 'utc'), | ||
updated_at timestamp without time zone default (now() at time zone 'utc'), | ||
deleted_at timestamp without time zone default NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.