mirror of
https://github.com/offen/website.git
synced 2024-12-23 05:20:21 +01:00
use mysql to work around psycopg2 issues in lambda
This commit is contained in:
parent
1c20b4ba58
commit
ad2a574338
@ -198,8 +198,7 @@ jobs:
|
||||
docker:
|
||||
- image: circleci/python:3.6
|
||||
environment:
|
||||
POSTGRES_CONNECTION_STRING: postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
||||
HASHED_PASSWORD: JDJhJDEwJGpFRXJMOVVSQndZQlFQNjkxallkZi53aGp1cDMvRW5maGUvakZleG1pWFlnWEVXcU93ODBp
|
||||
MYSQL_CONNECTION_STRING: mysql://root:circle@127.0.0.1:3306/circle
|
||||
JWT_PRIVATE_KEY: |-
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzgU18PnRrpbVK
|
||||
@ -239,10 +238,11 @@ jobs:
|
||||
a3B4L0waKzP5QWcO865n1HCUTnV+s4lNcphBDZCrSwTkXnVnQWVPCL7ssoQyM0u3
|
||||
HQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
- image: circleci/postgres:11.2-alpine
|
||||
- image: circleci/mysql:5.7
|
||||
environment:
|
||||
- POSTGRES_USER=circle
|
||||
- POSTGRES_PASSWORD=test
|
||||
- MYSQL_ROOT_PASSWORD=circle
|
||||
- MYSQL_DATABASE=circle
|
||||
- MYSQL_HOST=127.0.0.1
|
||||
working_directory: ~/offen/accounts
|
||||
steps:
|
||||
- checkout:
|
||||
@ -261,15 +261,15 @@ jobs:
|
||||
- ~/offen/accounts/venv
|
||||
key: offen-accounts-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
|
||||
- run:
|
||||
name: Waiting for Postgres to be ready
|
||||
name: Waiting for MySQL to be ready
|
||||
command: |
|
||||
for i in `seq 1 10`;
|
||||
do
|
||||
nc -z localhost 5432 && echo Success && exit 0
|
||||
nc -z localhost 3306 && echo Success && exit 0
|
||||
echo -n .
|
||||
sleep 1
|
||||
done
|
||||
echo Failed waiting for Postgres && exit 1
|
||||
echo Failed waiting for MySQL && exit 1
|
||||
- run:
|
||||
name: Run tests
|
||||
command: |
|
||||
|
@ -6,7 +6,7 @@ from flask_admin import Admin
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = environ.get("SESSION_SECRET")
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = environ.get("POSTGRES_CONNECTION_STRING")
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = environ.get("MYSQL_CONNECTION_STRING")
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
from accounts.models import Account, User
|
||||
|
@ -9,8 +9,8 @@ def generate_key():
|
||||
|
||||
class Account(db.Model):
|
||||
__tablename__ = "accounts"
|
||||
account_id = db.Column(db.String, primary_key=True, default=generate_key)
|
||||
name = db.Column(db.String, nullable=False, unique=True)
|
||||
account_id = db.Column(db.String(36), primary_key=True, default=generate_key)
|
||||
name = db.Column(db.String(256), nullable=False, unique=True)
|
||||
users = db.relationship("AccountUserAssociation", back_populates="account")
|
||||
|
||||
def __repr__(self):
|
||||
@ -19,9 +19,9 @@ class Account(db.Model):
|
||||
|
||||
class User(db.Model):
|
||||
__tablename__ = "users"
|
||||
user_id = db.Column(db.String, primary_key=True, default=generate_key)
|
||||
email = db.Column(db.String, nullable=False, unique=True)
|
||||
hashed_password = db.Column(db.String, nullable=False)
|
||||
user_id = db.Column(db.String(36), primary_key=True, default=generate_key)
|
||||
email = db.Column(db.String(256), nullable=False, unique=True)
|
||||
hashed_password = db.Column(db.String(256), nullable=False)
|
||||
accounts = db.relationship(
|
||||
"AccountUserAssociation", back_populates="user", lazy="joined"
|
||||
)
|
||||
@ -40,9 +40,9 @@ class AccountUserAssociation(db.Model):
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
user_id = db.Column(db.String, db.ForeignKey("users.user_id"), nullable=False)
|
||||
user_id = db.Column(db.String(36), db.ForeignKey("users.user_id"), nullable=False)
|
||||
account_id = db.Column(
|
||||
db.String, db.ForeignKey("accounts.account_id"), nullable=False
|
||||
db.String(36), db.ForeignKey("accounts.account_id"), nullable=False
|
||||
)
|
||||
|
||||
user = db.relationship("User", back_populates="accounts")
|
||||
|
@ -6,5 +6,6 @@ werkzeug==0.15.4
|
||||
pyjwt[crypto]==1.7.1
|
||||
passlib==1.7.1
|
||||
bcrypt==3.1.7
|
||||
psycopg2==2.8.3
|
||||
PyMySQL==0.9.3
|
||||
mysqlclient
|
||||
requests==2.22.0
|
||||
|
@ -25,9 +25,12 @@ services:
|
||||
POSTGRES_PASSWORD: develop
|
||||
|
||||
accounts_database:
|
||||
image: postgres:11.2
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: develop
|
||||
MYSQL_DATABASE: mysql
|
||||
MYSQL_ROOT_PASSWORD: develop
|
||||
|
||||
server:
|
||||
build:
|
||||
@ -116,7 +119,7 @@ services:
|
||||
environment:
|
||||
FLASK_APP: accounts:app
|
||||
FLASK_ENV: development
|
||||
POSTGRES_CONNECTION_STRING: postgres://postgres:develop@accounts_database:5432/postgres?sslmode=disable
|
||||
MYSQL_CONNECTION_STRING: mysql+pymysql://root:develop@accounts_database:3306/mysql
|
||||
CORS_ORIGIN: http://localhost:9977
|
||||
SERVER_HOST: http://server:8080
|
||||
SESSION_SECRET: vndJRFJTiyjfgtTF
|
||||
|
Loading…
Reference in New Issue
Block a user