Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
1f23ce68
Commit
1f23ce68
authored
Jan 9, 2023
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
Contraint champs formsemestre non nulls
parent
d0463fa1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/formsemestre.py
+7
-4
7 additions, 4 deletions
app/models/formsemestre.py
migrations/versions/554c13cea377_formsemestre_not_nulls.py
+66
-0
66 additions, 0 deletions
migrations/versions/554c13cea377_formsemestre_not_nulls.py
with
73 additions
and
4 deletions
app/models/formsemestre.py
+
7
−
4
View file @
1f23ce68
...
...
@@ -56,9 +56,9 @@ class FormSemestre(db.Model):
dept_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
"
departement.id
"
),
index
=
True
)
formation_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
"
notes_formations.id
"
))
semestre_id
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
1
,
server_default
=
"
1
"
)
titre
=
db
.
Column
(
db
.
Text
())
date_debut
=
db
.
Column
(
db
.
Date
())
date_fin
=
db
.
Column
(
db
.
Date
())
titre
=
db
.
Column
(
db
.
Text
()
,
nullable
=
False
)
date_debut
=
db
.
Column
(
db
.
Date
()
,
nullable
=
False
)
date_fin
=
db
.
Column
(
db
.
Date
()
,
nullable
=
False
)
etat
=
db
.
Column
(
db
.
Boolean
(),
nullable
=
False
,
default
=
True
,
server_default
=
"
true
"
)
# False si verrouillé
...
...
@@ -87,7 +87,10 @@ class FormSemestre(db.Model):
)
# couleur fond bulletins HTML:
bul_bgcolor
=
db
.
Column
(
db
.
String
(
SHORT_STR_LEN
),
default
=
"
white
"
,
server_default
=
"
white
"
db
.
String
(
SHORT_STR_LEN
),
default
=
"
white
"
,
server_default
=
"
white
"
,
nullable
=
False
,
)
# autorise resp. a modifier semestre:
resp_can_edit
=
db
.
Column
(
...
...
This diff is collapsed.
Click to expand it.
migrations/versions/554c13cea377_formsemestre_not_nulls.py
0 → 100644
+
66
−
0
View file @
1f23ce68
"""
formsemestre_not_nulls
Revision ID: 554c13cea377
Revises: 3c12f5850cff
Create Date: 2023-01-09 08:02:53.637488
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
"
554c13cea377
"
down_revision
=
"
3c12f5850cff
"
branch_labels
=
None
depends_on
=
None
def
upgrade
():
#
op
.
execute
(
"
UPDATE notes_formsemestre SET titre =
''
WHERE titre is NULL;
"
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
titre
"
,
existing_type
=
sa
.
TEXT
(),
nullable
=
False
)
op
.
execute
(
"
UPDATE notes_formsemestre SET date_debut = now() WHERE date_debut is NULL;
"
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
date_debut
"
,
existing_type
=
sa
.
DATE
(),
nullable
=
False
)
op
.
execute
(
"
UPDATE notes_formsemestre SET date_fin = now() WHERE date_fin is NULL;
"
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
date_fin
"
,
existing_type
=
sa
.
DATE
(),
nullable
=
False
)
op
.
execute
(
"
UPDATE notes_formsemestre SET bul_bgcolor =
'
white
'
WHERE bul_bgcolor is NULL;
"
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
bul_bgcolor
"
,
existing_type
=
sa
.
VARCHAR
(
length
=
32
),
nullable
=
False
,
existing_server_default
=
sa
.
text
(
"'
white
'
::character varying
"
),
)
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
alter_column
(
"
notes_formsemestre
"
,
"
bul_bgcolor
"
,
existing_type
=
sa
.
VARCHAR
(
length
=
32
),
nullable
=
True
,
existing_server_default
=
sa
.
text
(
"'
white
'
::character varying
"
),
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
date_fin
"
,
existing_type
=
sa
.
DATE
(),
nullable
=
True
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
date_debut
"
,
existing_type
=
sa
.
DATE
(),
nullable
=
True
)
op
.
alter_column
(
"
notes_formsemestre
"
,
"
titre
"
,
existing_type
=
sa
.
TEXT
(),
nullable
=
True
)
# ### end Alembic commands ###
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment