From 28b9b1e0ba46fe69278034019dfdd6412cd13f68 Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Mon, 9 Nov 2015 16:12:18 +0100
Subject: [PATCH] Drop TranscriptProteinLink database table

This data is now in Redis, by #94.

Fixes #95
---
 ...9f4836_drop_transcriptproteinlink_table.py | 34 +++++++++++++++++
 mutalyzer/db/models.py                        | 37 -------------------
 2 files changed, 34 insertions(+), 37 deletions(-)
 create mode 100644 migrations/versions/10692e9f4836_drop_transcriptproteinlink_table.py

diff --git a/migrations/versions/10692e9f4836_drop_transcriptproteinlink_table.py b/migrations/versions/10692e9f4836_drop_transcriptproteinlink_table.py
new file mode 100644
index 00000000..c32a4152
--- /dev/null
+++ b/migrations/versions/10692e9f4836_drop_transcriptproteinlink_table.py
@@ -0,0 +1,34 @@
+"""Drop TranscriptProteinLink table
+
+Revision ID: 10692e9f4836
+Revises: 1bf1b52f057
+Create Date: 2015-11-09 16:11:50.425722
+
+"""
+
+from __future__ import unicode_literals
+
+# revision identifiers, used by Alembic.
+revision = '10692e9f4836'
+down_revision = u'1bf1b52f057'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+def upgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    op.drop_table('transcript_protein_links')
+    ### end Alembic commands ###
+
+
+def downgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    op.create_table('transcript_protein_links',
+    sa.Column('id', sa.INTEGER(), nullable=False),
+    sa.Column('transcript_accession', sa.VARCHAR(length=20), autoincrement=False, nullable=True),
+    sa.Column('protein_accession', sa.VARCHAR(length=20), autoincrement=False, nullable=True),
+    sa.Column('added', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
+    sa.PrimaryKeyConstraint('id', name=u'transcript_protein_links_pkey')
+    )
+    ### end Alembic commands ###
diff --git a/mutalyzer/db/models.py b/mutalyzer/db/models.py
index 17d34186..90a94e19 100644
--- a/mutalyzer/db/models.py
+++ b/mutalyzer/db/models.py
@@ -214,43 +214,6 @@ Index('reference_slice',
       unique=True)
 
 
-# Todo: Perhaps it is a better fit to implement this with Redis.
-class TranscriptProteinLink(db.Base):
-    """
-    Cached link between a transcript and protein reference.
-    """
-    __tablename__ = 'transcript_protein_links'
-    __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
-
-    id = Column(Integer, primary_key=True)
-
-    #: Accession number for the transcript, not including the version number
-    #: (e.g., ``NM_018195`, ``XM_005270562``, ``NR_015380``). If `NULL`, the
-    #: record states that no transcript is linked to the protein.
-    transcript_accession = Column(String(20), nullable=True, index=True,
-                                  unique=True)
-
-    #: Accession number for the protein, not including the version number
-    #: (e.g., ``NP_060665``, ``XP_005258635``). If `NULL`, the record states
-    #: that no protein is linked to the transcript.
-    protein_accession = Column(String(20), nullable=True, index=True,
-                               unique=True)
-
-    #: Date and time of creation.
-    added = Column(DateTime)
-
-    def __init__(self, transcript_accession=None, protein_accession=None):
-        if transcript_accession is None and protein_accession is None:
-            raise ValueError('Link must have a transcript or protein')
-        self.transcript_accession = transcript_accession
-        self.protein_accession = protein_accession
-        self.added = datetime.now()
-
-    def __repr__(self):
-        return '<TranscriptProteinLink transcript=%r protein=%r>' \
-            % (self.transcript_accession, self.protein_accession)
-
-
 class Assembly(db.Base):
     """
     Genome assembly.
-- 
GitLab