Comments (3)
I created .py file of alembic and executed it successfully. Thanks! :)
"""create table
Revision ID: e7d7571bbcd3
Revises:
Create Date: 2020-01-09 19:44:30.527606
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e7d7571bbcd3'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'users',
sa.Column('id', sa.Integer, autoincrement=True, primary_key=True),
sa.Column('email', sa.String(120), unique=True, index=True),
sa.Column('f_name', sa.String(30), nullable=False),
sa.Column('m_name', sa.String(30), default=''),
sa.Column('l_name', sa.String(30), nullable=False),
sa.Column('password', sa.String(300), nullable=False),
sa.Column('is_deleted', sa.Boolean, default=False),
sa.Column('created_at', sa.TIMESTAMP(timezone=False), server_default=sa.func.current_timestamp()),
sa.Column('updated_at', sa.TIMESTAMP(timezone=False), onupdate=sa.func.current_timestamp())
)
op.create_table(
'link',
sa.Column('id', sa.Integer, autoincrement=True, primary_key=True),
sa.Column('long_url', sa.Unicode(1000), index=True),
sa.Column('protocol', sa.String(10), default='http://'),
sa.Column('domain', sa.String(300), ),
sa.Column('long_url_hash', sa.BigInteger, index=True),
sa.Column('short_code', sa.Unicode(6), unique=True, index=True, default=None),
sa.Column('description', sa.String(1000), default=None),
sa.Column('owner', sa.Integer, default=None),
sa.Column('secret_key', sa.String(12), default=''),
sa.Column('expire_after', sa.Integer, default=None),
sa.Column('is_default', sa.Boolean, default=False),
sa.Column('is_protected', sa.Boolean, default=False),
sa.Column('is_disabled', sa.Boolean, default=False),
sa.Column('is_custom', sa.Boolean, default=False),
sa.Column('created_at', sa.TIMESTAMP(timezone=False), server_default=sa.func.current_timestamp()),
sa.Column('updated_at', sa.TIMESTAMP(timezone=False), onupdate=sa.func.current_timestamp())
)
op.create_table(
'clickmeta',
sa.Column('id', sa.Integer, autoincrement=True, primary_key=True),
sa.Column('link_id', sa.Integer, sa.ForeignKey('link.id')),
sa.Column('country', sa.String(5), nullable=True),
sa.Column('referrer', sa.String(100), nullable=True),
sa.Column('created_at', sa.TIMESTAMP(timezone=False), server_default=sa.func.current_timestamp())
)
def downgrade():
op.drop_table('user', schema='production'),
op.drop_table('clickmeta', schema='production'),
op.drop_table('link', schema='production')
p.s.
I renamed user
table to users
.
from pygmy.
Hi,
Yes, currently it doesn't. Migrations through Alembic(https://alembic.sqlalchemy.org/en/latest/) was something that was planned but I didn't get to it. You can use it.
from pygmy.
Mm...I can't understand how to use alembic in order to migrate db...
from pygmy.
Related Issues (20)
- Make website responsive and mobile friendly HOT 3
- Handle duplicate custom link error gracefully
- About the `next_short_code` function HOT 5
- Add support for secret link stats HOT 1
- Add docker support and publish the image to hub HOT 3
- Feature request - randomised ids
- Disable Vanity HOT 2
- Secure the homepage to prevent access from outside HOT 1
- Link with an expiry time, shown as expired = False on dashboard even after expiry time
- When logged in user's token is expired, automatically logout the user
- Improve logging for raw and docker run
- Feature Request - Simplified Flask Implementation HOT 2
- Show country with country code on URL stats page HOT 1
- Improve "Already shortened URL" message HOT 1
- Feature Request - Word-specific URLs
- 400: Malicious Attacks HOT 4
- python3 run.py: infinite loop
- Production config files example HOT 1
- changing shorturl direction link
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygmy.